Ejemplo n.º 1
0
        public static MyStorageBase LoadFromFile(string absoluteFilePath)
        {
            const string loadingMessage = "Loading voxel storage from file '{0}'";

            if (!MyFileSystem.FileExists(absoluteFilePath))
            {
                var oldPath = Path.ChangeExtension(absoluteFilePath, "vox");
                MySandboxGame.Log.WriteLine(string.Format(loadingMessage, oldPath));
                UpdateFileFormat(oldPath);
                Debug.Assert(MyFileSystem.FileExists(absoluteFilePath));
            }
            else
            {
                MySandboxGame.Log.WriteLine(string.Format(loadingMessage, absoluteFilePath));
            }
            Debug.Assert(absoluteFilePath.EndsWith(MyVoxelConstants.FILE_EXTENSION));

            byte[] compressedData = null;
            using (var file = MyFileSystem.OpenRead(absoluteFilePath))
            {
                compressedData = new byte[file.Length];
                file.Read(compressedData, 0, compressedData.Length);
            }
            return(Load(compressedData));
        }
Ejemplo n.º 2
0
 private static string GetTextureToBase64(string filename, int width, int height, bool ignoreAlpha = false)
 {
     using (Stream stream = MyFileSystem.OpenRead(filename))
     {
         return(ImageTextureUtil.GetTextureToBase64(stream, filename, width, height, ignoreAlpha));
     }
 }
Ejemplo n.º 3
0
        internal static MyShaderPass GetOrCreate(string tag)
        {
            MyShaderPass cached;
            bool         rebuild = false;

            if (!m_cached.TryGetValue(tag, out cached))
            {
                cached        = new MyShaderPass();
                rebuild       = true;
                m_cached[tag] = cached;
            }

            if (rebuild)
            {
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, "Shaders/passes", tag), "vertex_stage.hlsl"))
                {
                    cached.m_vertexStageSrc = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, "Shaders/passes", tag), "pixel_stage.hlsl"))
                {
                    cached.m_pixelStageSrc = new StreamReader(stream).ReadToEnd();
                }
            }

            return(cached);
        }
Ejemplo n.º 4
0
        public MyInMemoryWave(MySoundData cue, string path, MyWaveBank owner, bool streamed = false)
        {
            using (var stream = MyFileSystem.OpenRead(path))
            {
                m_owner      = owner;
                m_path       = path;
                m_stream     = new SoundStream(stream);
                m_waveFormat = m_stream.Format;
                m_buffer     = new AudioBuffer
                {
                    Stream     = m_stream.ToDataStream(),
                    AudioBytes = (int)m_stream.Length,
                    Flags      = BufferFlags.None
                };

                if (cue.Loopable)
                {
                    m_buffer.LoopCount = AudioBuffer.LoopInfinite;
                }

                m_stream.Close();

                Streamed = streamed;
            }
        }
        public static bool DeserializeXML(string path, out MyObjectBuilder_Base objectBuilder, Type builderType)
        {
            bool result = false;

            objectBuilder = null;
            using (var fileStream = MyFileSystem.OpenRead(path))
            {
                if (fileStream != null)
                {
                    using (var readStream = fileStream.UnwrapGZip())
                    {
                        if (readStream != null)
                        {
                            result = DeserializeXML(readStream, out objectBuilder, builderType);
                        }
                    }
                }
            }

            if (!result)
            {
                MyLog.Default.WriteLine(string.Format("Failed to deserialize file '{0}'", path));
            }

            return(result);
        }
        public static bool DeserializeXML <T>(string path, out T objectBuilder, out ulong fileSize) where T : MyObjectBuilder_Base
        {
            bool result = false;

            fileSize      = 0;
            objectBuilder = null;

            using (var fileStream = MyFileSystem.OpenRead(path))
            {
                if (fileStream != null)
                {
                    using (var readStream = fileStream.UnwrapGZip())
                    {
                        if (readStream != null)
                        {
                            fileSize = (ulong)fileStream.Length;
                            result   = DeserializeXML(readStream, out objectBuilder);
                        }
                    }
                }
            }

            if (!result)
            {
                MyLog.Default.WriteLine(string.Format("Failed to deserialize file '{0}'", path));
            }

            return(result);
        }
Ejemplo n.º 7
0
        private void ReadScripts(string path)
        {
            var fsPath      = Path.Combine(path, "Data", "Scripts");
            var scriptFiles = MyFileSystem.GetFiles(fsPath, "*.cs");//, searchOption: VRage.FileSystem.SearchOption.TopDirectoryOnly);

            try
            {
                if (scriptFiles.Count() == 0)
                {
                    return;
                }
            }
            catch (Exception)
            {
                MySandboxGame.Log.WriteLine(string.Format("Failed to load scripts from: {0}", path));
                return;
            }
            foreach (var file in scriptFiles)
            {
                try
                {
                    var stream = MyFileSystem.OpenRead(file);
                    using (var sr = new StreamReader(stream))
                    {
                        m_scriptsToSave.Add(file.Substring(fsPath.Length + 1), sr.ReadToEnd());
                    }
                }
                catch (Exception e)
                {
                    MySandboxGame.Log.WriteLine(e);
                }
            }
        }
Ejemplo n.º 8
0
        private static MyTextureAtlas LoadTextureAtlas(string textureDir, string atlasFile)
        {
            MyTextureAtlas atlas = new MyTextureAtlas(0x40);

            using (Stream stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, atlasFile)))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string str = reader.ReadLine();
                        if (!str.StartsWith("#"))
                        {
                            char[] trimChars = new char[] { ' ' };
                            if (str.Trim(trimChars).Length != 0)
                            {
                                string[]           strArray  = str.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);
                                string             str3      = strArray[1];
                                Vector4            uvOffsets = new Vector4(Convert.ToSingle(strArray[4], CultureInfo.InvariantCulture), Convert.ToSingle(strArray[5], CultureInfo.InvariantCulture), Convert.ToSingle(strArray[7], CultureInfo.InvariantCulture), Convert.ToSingle(strArray[8], CultureInfo.InvariantCulture));
                                MyTextureAtlasItem item      = new MyTextureAtlasItem(textureDir + str3, uvOffsets);
                                atlas.Add(strArray[0], item);
                            }
                        }
                    }
                }
            }
            return(atlas);
        }
Ejemplo n.º 9
0
        private void ScriptSelected(string scriptPath)
        {
            string programData   = null;
            string fileExtension = Path.GetExtension(scriptPath);

            if (fileExtension == MyGuiIngameScriptsPage.SCRIPT_EXTENSION && File.Exists(scriptPath))
            {
                programData = File.ReadAllText(scriptPath);
            }
            else if (fileExtension == MyGuiIngameScriptsPage.WORKSHOP_SCRIPT_EXTENSION)
            {
                foreach (var file in MyFileSystem.GetFiles(scriptPath, MyGuiIngameScriptsPage.SCRIPT_EXTENSION, VRage.FileSystem.MySearchOption.AllDirectories))
                {
                    if (MyFileSystem.FileExists(file))
                    {
                        using (var stream = MyFileSystem.OpenRead(file))
                        {
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                programData = reader.ReadToEnd();
                            }
                        }
                    }
                }
            }
            if (programData != null)
            {
                SetDescription(Regex.Replace(programData, "\r\n", " \n"));
                m_lineCounter.Text = string.Format(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_LineNo), m_editorWindow.GetCurrentCarriageLine(), m_editorWindow.GetTotalNumLines());
                EnableButtons();
            }
        }
Ejemplo n.º 10
0
        internal static MyShaderMaterial GetOrCreate(string name)
        {
            MyShaderMaterial cached;
            bool             rebuild = false;

            if (!m_cached.TryGetValue(name, out cached))
            {
                cached             = new MyShaderMaterial();
                cached.m_id        = m_cached.Count;
                m_map[cached.m_id] = name;
                rebuild            = true;
                m_cached[name]     = cached;
            }

            if (rebuild)
            {
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, "Shaders/materials", name), "declarations.h"))
                {
                    cached.m_declarationsSrc = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, "Shaders/materials", name), "vertex.h"))
                {
                    cached.m_vertexProgramSrc = new StreamReader(stream).ReadToEnd();
                }
                using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, "Shaders/materials", name), "pixel.h"))
                {
                    cached.m_pixelProgramSrc = new StreamReader(stream).ReadToEnd();
                }
            }

            return(cached);
        }
Ejemplo n.º 11
0
        private static void PatchTexts(string resourceFile)
        {
            if (!File.Exists(resourceFile))
            {
                return;
            }

            using (var stream = MyFileSystem.OpenRead(resourceFile))
                using (var reader = new ResXResourceReader(stream))
                {
                    foreach (DictionaryEntry entry in reader)
                    {
                        string key   = entry.Key as string;
                        string value = entry.Value as string;

                        Debug.Assert(key != null && value != null, string.Format("Text has incorrect format. [{0}:{1}]", key.GetType().Name, value.GetType().Name));
                        if (key == null || value == null)
                        {
                            continue;
                        }

                        var id = MyStringId.GetOrCompute(key);
                        m_strings[id]        = value;
                        m_stringBuilders[id] = new StringBuilder(value);
                    }
                }
        }
Ejemplo n.º 12
0
        public static string[] UpdateCompatibility(string[] files)
        {
            string[] sources = new string[files.Length];
            for (int i = 0; i < files.Length; ++i)
            {
                using (Stream stream = MyFileSystem.OpenRead(files[i]))
                {
                    if (stream != null)
                    {
                        using (StreamReader sr = new StreamReader(stream))
                        {
                            string source = sr.ReadToEnd();

                            Debug.Assert(CompatibilityUsings != null, "Compatibility usings can't be null");
                            source = source.Insert(0, CompatibilityUsings);

                            foreach (var value in m_compatibilityChanges)
                            {
                                source = source.Replace(value.Key, value.Value);
                            }
                            sources[i] = source;
                        }
                    }
                }
            }
            return(sources);
        }
Ejemplo n.º 13
0
 static public void Deserialize(string file)
 {
     try
     {
         var path = Path.Combine(MyFileSystem.ContentPath, file);
         using (var fs = MyFileSystem.OpenRead(path))
         {
             XmlReaderSettings settings = new XmlReaderSettings()
             {
                 IgnoreWhitespace = true,
             };
             using (XmlReader reader = XmlReader.Create(fs, settings))
             {
                 Deserialize(reader);
             }
         }
     }
     catch (IOException ex)
     {
         MyLog.Default.WriteLine("ERROR: Failed to load particles library.");
         MyLog.Default.WriteLine(ex);
         WinApi.MessageBox(new IntPtr(), ex.Message, "Loading Error", 0);
         throw;
     }
 }
Ejemplo n.º 14
0
        private void Compile(IEnumerable <string> scriptFiles, string assemblyName, bool zipped, MyModContext context)
        {
#if XB1
            System.Diagnostics.Debug.Assert(false, "Unsupported runtime script compilation on XB1.");
#else
            Assembly assembly = null;
            bool     compiled = false;
            if (zipped)
            {
                var tmp = Path.GetTempPath();
                foreach (var file in scriptFiles)
                {
                    try
                    {
                        var newPath = string.Format("{0}{1}", tmp, Path.GetFileName(file));
                        var stream  = MyFileSystem.OpenRead(file);
                        using (var sr = new StreamReader(stream))
                        {
                            stream = MyFileSystem.OpenWrite(newPath);// (newPath);
                            using (var sw = new StreamWriter(stream))
                            {
                                sw.Write(sr.ReadToEnd()); //create file in tmp for debugging
                            }
                        }
                        m_cachedFiles.Add(newPath);
                    }
                    catch (Exception e)
                    {
                        MySandboxGame.Log.WriteLine(e);
                        MyDefinitionErrors.Add(context, string.Format("Cannot load {0}", Path.GetFileName(file)), TErrorSeverity.Error);
                        MyDefinitionErrors.Add(context, e.Message, TErrorSeverity.Error);
                    }
                }
                compiled = IlCompiler.CompileFileModAPI(assemblyName, m_cachedFiles.ToArray(), out assembly, m_errors);
            }
            else
            {
                compiled = IlCompiler.CompileFileModAPI(assemblyName, scriptFiles.ToArray(), out assembly, m_errors);
            }
            Debug.Assert(compiled == (assembly != null), "Compile results inconsistency!");
            if (assembly != null && compiled)
            {
                AddAssembly(context, MyStringId.GetOrCompute(assemblyName), assembly);
            }
            else
            {
                MyDefinitionErrors.Add(context, string.Format("Compilation of {0} failed:", assemblyName), TErrorSeverity.Error);
                MySandboxGame.Log.IncreaseIndent();
                foreach (var error in m_errors)
                {
                    MyDefinitionErrors.Add(context, error.ToString(), TErrorSeverity.Error);
                    Debug.Assert(false, error.ToString());
                }
                MySandboxGame.Log.DecreaseIndent();
                m_errors.Clear();
            }
            m_cachedFiles.Clear();
#endif
        }
Ejemplo n.º 15
0
 public static void HashInFile(string fileName)
 {
     using (Stream stream = MyFileSystem.OpenRead(fileName).UnwrapGZip())
     {
         HashInData(fileName.ToLower(), stream);
     }
     MySandboxGame.Log.WriteLine(GetHashHex());
 }
Ejemplo n.º 16
0
        protected override BaseTexture LoadPNGTexture(string fileName)
        {
            var path = Path.Combine(MyFileSystem.ContentPath, fileName);

            using (var stream = MyFileSystem.OpenRead(path))
            {
                return(Texture.FromStream(MyRender.GraphicsDevice, stream));
            }
        }
Ejemplo n.º 17
0
        private static MyTextureAtlas LoadTextureAtlas(string textureDir, string atlasFile)
        {
            var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile);

            if (!File.Exists(fsPath))
            {
                MyLog.Default.WriteLine("Warning: " + atlasFile + " not found.");
                return(null);
            }

            try
            {
                var atlas = new MyTextureAtlas(64);

                using (var file = MyFileSystem.OpenRead(fsPath))
                    using (StreamReader sr = new StreamReader(file))
                    {
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();

                            if (line.StartsWith("#"))
                            {
                                continue;
                            }
                            if (line.Trim(' ').Length == 0)
                            {
                                continue;
                            }

                            string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);

                            string name      = parts[0];
                            string atlasName = parts[1];

                            Vector4 uv = new Vector4(
                                Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture));

                            MyTexture2D        atlasTexture = MyTextureManager.GetTexture <MyTexture2D>(textureDir + atlasName);
                            MyTextureAtlasItem item         = new MyTextureAtlasItem(atlasTexture, uv);
                            atlas.Add(name, item);
                        }
                    }

                return(atlas);
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Warning: " + e.ToString());
            }

            return(null);
        }
Ejemplo n.º 18
0
        private void Compile(IEnumerable <string> scriptFiles, string assemblyName, bool zipped)
        {
            Assembly assembly = null;
            var      c        = new MyModContext();

            c.Init(assemblyName, assemblyName);
            if (zipped)
            {
                var tmp = Path.GetTempPath();
                foreach (var file in scriptFiles)
                {
                    try
                    {
                        var newPath = string.Format("{0}{1}", tmp, Path.GetFileName(file));
                        var stream  = MyFileSystem.OpenRead(file);
                        using (var sr = new StreamReader(stream))
                        {
                            stream = MyFileSystem.OpenWrite(newPath);// (newPath);
                            using (var sw = new StreamWriter(stream))
                            {
                                sw.Write(sr.ReadToEnd()); //create file in tmp for debugging
                            }
                        }
                        m_cachedFiles.Add(newPath);
                    }
                    catch (Exception e)
                    {
                        MySandboxGame.Log.WriteLine(e);
                        MyDefinitionErrors.Add(c, string.Format("Cannot load {0}", Path.GetFileName(file)), ErrorSeverity.Error);
                        MyDefinitionErrors.Add(c, e.Message, ErrorSeverity.Error);
                    }
                }
                IlCompiler.CompileFileModAPI(assemblyName, m_cachedFiles.ToArray(), out assembly, m_errors);
            }
            else
            {
                IlCompiler.CompileFileModAPI(assemblyName, scriptFiles.ToArray(), out assembly, m_errors);
            }
            if (assembly != null)
            {
                AddAssembly(MyStringId.GetOrCompute(assemblyName), assembly);
            }
            else
            {
                MyDefinitionErrors.Add(c, string.Format("Compilation of {0} failed:", assemblyName), ErrorSeverity.Error);
                MySandboxGame.Log.IncreaseIndent();
                foreach (var error in m_errors)
                {
                    MyDefinitionErrors.Add(c, error.ToString(), ErrorSeverity.Error);
                    Debug.Assert(false, error.ToString());
                }
                MySandboxGame.Log.DecreaseIndent();
                m_errors.Clear();
            }
            m_cachedFiles.Clear();
        }
Ejemplo n.º 19
0
        private void LoadFontXML()
        {
            var xd = new XmlDocument();

            using (var stream = MyFileSystem.OpenRead(path))
            {
                xd.Load(stream);
            }
            LoadFontXML(xd.ChildNodes);
        }
Ejemplo n.º 20
0
 private Image LoadTexture(string path)
 {
     if (!MyFileSystem.FileExists(path))
     {
         return(null);
     }
     using (Stream stream = MyFileSystem.OpenRead(path))
     {
         return((stream != null) ? Image.Load(stream) : null);
     }
 }
Ejemplo n.º 21
0
        public static void HashInFile(string fileName)
        {
            //MySandboxGame.Log.WriteLine("Hashing file " + fileName + " into data check hash");

            using (var file = MyFileSystem.OpenRead(fileName).UnwrapGZip())
            {
                HashInData(fileName.ToLower(), file);
            }

            MySandboxGame.Log.WriteLine(GetHashHex());
        }
        private static Image LoadTexture(string path)
        {
            if (!MyFileSystem.FileExists(path))
            {
                return(null);
            }

            using (Stream textureStream = MyFileSystem.OpenRead(path))
            {
                return(textureStream != null?SharpDXImage.Load(textureStream) : null);
            }
        }
Ejemplo n.º 23
0
        static void LoadTemplates()
        {
            using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "vertex_template_base.h")))
            {
                m_vertexTemplateBase = new StreamReader(stream).ReadToEnd();
            }

            using (var stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.ContentPath, MyShadersDefines.ShadersContentPath, "pixel_template_base.h")))
            {
                m_pixelTemplateBase = new StreamReader(stream).ReadToEnd();
            }
        }
Ejemplo n.º 24
0
        public void ImportData(string assetFileName, string[] tags = null)
        {
            Clear();
            var path = Path.IsPathRooted(assetFileName) ? assetFileName : Path.Combine(MyFileSystem.ContentPath, assetFileName);

            using (var fs = MyFileSystem.OpenRead(path))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    LoadTagData(reader, tags);
                }
            }
        }
Ejemplo n.º 25
0
        static void ParseAtlasDescription(string textureDir, string atlasFile, out Dictionary <string, Element> atlasDict)
        {
            atlasDict = new Dictionary <string, Element>();
            MyFileTextureManager texManager = MyManagers.FileTextures;

            try
            {
                //var atlas = new MyTextureAtlas(64);
                var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile);
                using (var file = MyFileSystem.OpenRead(fsPath))
                    using (StreamReader sr = new StreamReader(file))
                    {
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();

                            if (line.StartsWith("#"))
                            {
                                continue;
                            }
                            if (line.Trim(' ').Length == 0)
                            {
                                continue;
                            }

                            string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);

                            string name      = parts[0];
                            string atlasName = parts[1];

                            Vector4 uv = new Vector4(
                                Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture),
                                Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture));

                            name = textureDir + System.IO.Path.GetFileName(name);
                            var atlasTexture = textureDir + atlasName;

                            var element = new Element();
                            element.Texture       = texManager.GetTexture(atlasTexture, MyFileTextureEnum.GUI, true);
                            element.UvOffsetScale = uv;
                            atlasDict[name]       = element;
                        }
                    }
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLine("Warning: " + e.ToString());
            }
        }
    BinaryReader IMyUtilities.ReadBinaryFileInGlobalStorage(string file)
    {
        if (file.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
        {
            throw new FileNotFoundException();
        }
        Stream stream = MyFileSystem.OpenRead(Path.Combine(MyFileSystem.UserDataPath, "Storage", file));

        if (stream != null)
        {
            return(new BinaryReader(stream));
        }
        throw new FileNotFoundException();
    }
    BinaryReader IMyUtilities.ReadBinaryFileInWorldStorage(string file, Type callingType)
    {
        if (file.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
        {
            throw new FileNotFoundException();
        }
        Stream stream = MyFileSystem.OpenRead(Path.Combine(MySession.Static.CurrentPath, "Storage", StripDllExtIfNecessary(callingType.Assembly.ManifestModule.ScopeName), file));

        if (stream != null)
        {
            return(new BinaryReader(stream));
        }
        throw new FileNotFoundException();
    }
Ejemplo n.º 28
0
        /// <summary>
        /// Reads a file in the storage folder at the given path. The calling type is used
        /// to get the assembly name to get the sub directory in the storage folder, where files for the dll are stored.
        /// The calling type is used to get the assembly name to get the sub directory in the storage folder, where files for the dll are stored.
        /// </summary>
        /// <param name="path">Path to the storage folder</param>
        /// <param name="file">File name</param>
        /// <param name="callingType">Dalling type</param>
        /// <returns>Returns a TextReader of the read file</returns>
        public static TextReader ReadFileInPath(string path, string file, Type callingType)
        {
            if (file.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
            {
                throw new FileNotFoundException();
            }
            var paths  = Path.Combine(path, STORAGE_FOLDER, StripDllExtIfNecessary(callingType.Assembly.ManifestModule.ScopeName), file);
            var stream = MyFileSystem.OpenRead(paths);

            if (stream != null)
            {
                return(new StreamReader(stream));
            }
            throw new FileNotFoundException();
        }
Ejemplo n.º 29
0
        System.IO.TextReader IMyUtilities.ReadFileInLocalStorage(string file, Type callingType)
        {
            if (file.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
            {
                throw new FileNotFoundException();
            }
            var path   = Path.Combine(MyFileSystem.UserDataPath, STORAGE_FOLDER, callingType.Assembly.ManifestModule.ScopeName, file);
            var stream = MyFileSystem.OpenRead(path);

            if (stream != null)
            {
                return(new StreamReader(stream));
            }
            throw new FileNotFoundException();
        }
Ejemplo n.º 30
0
        public void ImportData(string assetFileName, string[] tags = null)
        {
            Clear();
            m_debugAssetName = assetFileName;
            var path = Path.IsPathRooted(assetFileName) ? assetFileName : Path.Combine(MyFileSystem.ContentPath, assetFileName);

            using (var fs = MyFileSystem.OpenRead(path))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    LoadTagData(reader, tags);
                }
                fs.Close(); // OM: Although this shouldn't be needed, we experience problems with opening files with autorefresh, is this isn't called explicitely..
            }
        }