Example #1
0
        public static List <VFile> LoadVersions(string filename, bool update = false)
        {
            var rootDir = Path.GetDirectoryName(filename);
            var data    = update ? _updateData : _baseData;

            data.Clear();
            using (var stream = File.OpenRead(filename)) {
                var reader = new BinaryReader(stream);
                var list   = new List <VFile> ();
                var ver    = reader.ReadInt32();
                Debug.Log("LoadVersions:" + ver);
                var count = reader.ReadInt32();
                for (var i = 0; i < count; i++)
                {
                    var version = new VFile();
                    version.Deserialize(reader);
                    list.Add(version);
                    data [version.name] = version;
                    var dir = string.Format("{0}/{1}", rootDir, Path.GetDirectoryName(version.name));
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                }
                return(list);
            }
        }
Example #2
0
        public bool Load(string path)
        {
            if (!File.Exists(path))
            {
                return(false);
            }

            Clear();

            name = path;
            using (var reader = new BinaryReader(File.OpenRead(path)))
            {
                var count = reader.ReadInt32();
                for (var i = 0; i < count; i++)
                {
                    var file = new VFile {
                        id = i
                    };
                    file.Deserialize(reader);
                    AddFile(file);
                }

                _pos = reader.BaseStream.Position;
            }

            Reindex();
            return(true);
        }
Example #3
0
        public void Deserialize(BinaryReader reader)
        {
            ver = reader.ReadInt32();
            var count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var file = new VFile();
                file.Deserialize(reader);
                files.Add(file);
                _dataFiles[file.name] = file;
            }
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var patch = new VPatch();
                patch.Deserialize(reader);
                patches.Add(patch);
                _dataPatches[patch.id] = patch;
            }
        }
        public static List <VFile> LoadVersions(string filename, bool update = false)
        {
            var data = update ? _updateData : _baseData;

            data.Clear();
            using (var stream = File.OpenRead(filename)) {
                var reader = new BinaryReader(stream);
                var list   = new List <VFile> ();
                var ver    = reader.ReadInt32();
                Debug.Log("LoadVersions:" + ver);
                var count = reader.ReadInt32();
                for (var i = 0; i < count; i++)
                {
                    var version = new VFile();
                    version.Deserialize(reader);
                    list.Add(version);
                    data [version.name] = version;
                }
                return(list);
            }
        }