diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 123 |
1 files changed, 84 insertions, 39 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index bc5df11..0299385 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1343,10 +1343,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1343 | 1343 | ||
1344 | try | 1344 | try |
1345 | { | 1345 | { |
1346 | FileStream tfs = File.Open(assemName + ".text", | 1346 | using (FileStream tfs = File.Open(assemName + ".text", |
1347 | FileMode.Open, FileAccess.Read); | 1347 | FileMode.Open, FileAccess.Read)) |
1348 | tfs.Read(tdata, 0, tdata.Length); | 1348 | { |
1349 | tfs.Close(); | 1349 | tfs.Read(tdata, 0, tdata.Length); |
1350 | tfs.Close(); | ||
1351 | } | ||
1350 | 1352 | ||
1351 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | 1353 | assem = new System.Text.ASCIIEncoding().GetString(tdata); |
1352 | } | 1354 | } |
@@ -1366,9 +1368,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1366 | 1368 | ||
1367 | try | 1369 | try |
1368 | { | 1370 | { |
1369 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | 1371 | using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) |
1370 | fs.Read(data, 0, data.Length); | 1372 | { |
1371 | fs.Close(); | 1373 | fs.Read(data, 0, data.Length); |
1374 | fs.Close(); | ||
1375 | } | ||
1372 | 1376 | ||
1373 | assem = System.Convert.ToBase64String(data); | 1377 | assem = System.Convert.ToBase64String(data); |
1374 | } | 1378 | } |
@@ -1384,13 +1388,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1384 | 1388 | ||
1385 | if (File.Exists(fn + ".map")) | 1389 | if (File.Exists(fn + ".map")) |
1386 | { | 1390 | { |
1387 | FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); | 1391 | using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read)) |
1388 | StreamReader msr = new StreamReader(mfs); | 1392 | { |
1389 | 1393 | using (StreamReader msr = new StreamReader(mfs)) | |
1390 | map = msr.ReadToEnd(); | 1394 | { |
1391 | 1395 | map = msr.ReadToEnd(); | |
1392 | msr.Close(); | 1396 | msr.Close(); |
1393 | mfs.Close(); | 1397 | } |
1398 | mfs.Close(); | ||
1399 | } | ||
1394 | } | 1400 | } |
1395 | 1401 | ||
1396 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | 1402 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); |
@@ -1478,30 +1484,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1478 | { | 1484 | { |
1479 | Byte[] filedata = Convert.FromBase64String(base64); | 1485 | Byte[] filedata = Convert.FromBase64String(base64); |
1480 | 1486 | ||
1481 | FileStream fs = File.Create(path); | 1487 | try |
1482 | fs.Write(filedata, 0, filedata.Length); | 1488 | { |
1483 | fs.Close(); | 1489 | using (FileStream fs = File.Create(path)) |
1484 | 1490 | { | |
1485 | fs = File.Create(path + ".text"); | 1491 | fs.Write(filedata, 0, filedata.Length); |
1486 | StreamWriter sw = new StreamWriter(fs); | 1492 | fs.Close(); |
1487 | 1493 | } | |
1488 | sw.Write(base64); | 1494 | } |
1489 | 1495 | catch (IOException ex) | |
1490 | sw.Close(); | 1496 | { |
1491 | fs.Close(); | 1497 | // if there already exists a file at that location, it may be locked. |
1498 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | ||
1499 | } | ||
1500 | try | ||
1501 | { | ||
1502 | using (FileStream fs = File.Create(path + ".text")) | ||
1503 | { | ||
1504 | using (StreamWriter sw = new StreamWriter(fs)) | ||
1505 | { | ||
1506 | sw.Write(base64); | ||
1507 | sw.Close(); | ||
1508 | } | ||
1509 | fs.Close(); | ||
1510 | } | ||
1511 | } | ||
1512 | catch (IOException ex) | ||
1513 | { | ||
1514 | // if there already exists a file at that location, it may be locked. | ||
1515 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | ||
1516 | } | ||
1492 | } | 1517 | } |
1493 | } | 1518 | } |
1494 | 1519 | ||
1495 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | 1520 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); |
1496 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); | 1521 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); |
1497 | 1522 | ||
1498 | FileStream sfs = File.Create(statepath); | 1523 | try |
1499 | StreamWriter ssw = new StreamWriter(sfs); | 1524 | { |
1500 | 1525 | using (FileStream sfs = File.Create(statepath)) | |
1501 | ssw.Write(stateE.OuterXml); | 1526 | { |
1502 | 1527 | using (StreamWriter ssw = new StreamWriter(sfs)) | |
1503 | ssw.Close(); | 1528 | { |
1504 | sfs.Close(); | 1529 | ssw.Write(stateE.OuterXml); |
1530 | ssw.Close(); | ||
1531 | } | ||
1532 | sfs.Close(); | ||
1533 | } | ||
1534 | } | ||
1535 | catch (IOException ex) | ||
1536 | { | ||
1537 | // if there already exists a file at that location, it may be locked. | ||
1538 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | ||
1539 | } | ||
1505 | 1540 | ||
1506 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | 1541 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); |
1507 | if (mapL.Count > 0) | 1542 | if (mapL.Count > 0) |
@@ -1511,13 +1546,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1511 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | 1546 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); |
1512 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | 1547 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); |
1513 | 1548 | ||
1514 | FileStream mfs = File.Create(mappath); | 1549 | try |
1515 | StreamWriter msw = new StreamWriter(mfs); | 1550 | { |
1516 | 1551 | using (FileStream mfs = File.Create(mappath)) | |
1517 | msw.Write(mapE.InnerText); | 1552 | { |
1518 | 1553 | using (StreamWriter msw = new StreamWriter(mfs)) | |
1519 | msw.Close(); | 1554 | { |
1520 | mfs.Close(); | 1555 | msw.Write(mapE.InnerText); |
1556 | msw.Close(); | ||
1557 | } | ||
1558 | mfs.Close(); | ||
1559 | } | ||
1560 | } | ||
1561 | catch (IOException ex) | ||
1562 | { | ||
1563 | // if there already exists a file at that location, it may be locked. | ||
1564 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | ||
1565 | } | ||
1521 | } | 1566 | } |
1522 | 1567 | ||
1523 | return true; | 1568 | return true; |