diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index e1362f9089..39ebb1c25c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -353,30 +353,58 @@ namespace OpenSim.Region.Framework.Scenes if (fn == String.Empty) continue; - FileInfo fi = new FileInfo(assembly); + String filedata = String.Empty; - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try + if (File.Exists(assembly+".text")) { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } + FileInfo tfi = new FileInfo(assembly+".text"); + if (tfi == null) + continue; + + Byte[] tdata = new Byte[tfi.Length]; + + try + { + FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + } + catch (Exception e) + { + m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); + } + + filedata = new System.Text.ASCIIEncoding().GetString(tdata); + } + else + { + FileInfo fi = new FileInfo(assembly); + + if (fi == null) + continue; + + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + } + catch (Exception e) + { + m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); + } + + filedata = System.Convert.ToBase64String(data); + } XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); assemblyName.Value = fn; assemblyData.Attributes.Append(assemblyName); - assemblyData.InnerText = System.Convert.ToBase64String(data); + assemblyData.InnerText = filedata; wrapper.AppendChild(assemblyData); } @@ -441,6 +469,11 @@ namespace OpenSim.Region.Framework.Scenes FileStream fs = File.Create(path); fs.Write(filedata, 0, filedata.Length); fs.Close(); + + Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText); + fs = File.Create(path+".text"); + fs.Write(textbytes, 0, textbytes.Length); + fs.Close(); } } break; diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 5d8f445a4d..5b3dce7152 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -343,7 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // Check this late so the map is generated on sim start // - if (File.Exists(OutFile)) + if (File.Exists(OutFile) && File.Exists(OutFile+".text")) { // m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset); return OutFile; @@ -579,6 +579,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } // m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly "+ // "for {0}", asset); + + // Because windows likes to perform exclusive locks, we simply + // write out a textual representation of the file here + // + // Read the binary file into a buffer + // + FileInfo fi = new FileInfo(OutFile); + + if (fi == null) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to stat file."; + throw new Exception(errtext); + } + + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + } + catch (Exception e) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to open file."; + throw new Exception(errtext); + } + + // Convert to base64 + // + string filetext = System.Convert.ToBase64String(data); + + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + + Byte[] buf = enc.GetBytes(filetext); + + FileStream sfs = File.Create(OutFile+".text"); + sfs.Write(buf, 0, buf.Length); + sfs.Close(); + return OutFile; } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a5570b3dab..7a36bc24e2 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -744,8 +744,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (File.Exists(m_Assemblies[assetID])) File.Delete(m_Assemblies[assetID]); - if (File.Exists(m_Assemblies[assetID]+".state")) - File.Delete(m_Assemblies[assetID]+".state"); + if (File.Exists(m_Assemblies[assetID]+".text")) + File.Delete(m_Assemblies[assetID]+".text"); if (File.Exists(m_Assemblies[assetID]+".mdb")) File.Delete(m_Assemblies[assetID]+".mdb");