LoadFromBinary() public static method

Loads a FileNode from stream.
public static LoadFromBinary ( BinaryReader stream, long streamLength = -1 ) : VdfFileNode
stream System.IO.BinaryReader Stream to load from
streamLength long
return VdfFileNode
Exemplo n.º 1
0
        public static Dictionary <int, AppInfo> LoadApps(string path)
        {
            Dictionary <int, AppInfo> result = new Dictionary <int, AppInfo>();
            BinaryReader bReader             = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read));
            long         fileLength          = bReader.BaseStream.Length;

            // seek to common: start of a new entry
            byte[] start = new byte[] { 0x00, 0x00, 0x63, 0x6F, 0x6D, 0x6D, 0x6F, 0x6E, 0x00 }; // 0x00 0x00 c o m m o n 0x00

            VdfFileNode.ReadBin_SeekTo(bReader, start, fileLength);

            VdfFileNode node = VdfFileNode.LoadFromBinary(bReader, fileLength);

            while (node != null)
            {
                AppInfo app = AppInfo.FromVdfNode(node);
                if (app != null)
                {
                    result.Add(app.Id, app);
                }
                VdfFileNode.ReadBin_SeekTo(bReader, start, fileLength);
                node = VdfFileNode.LoadFromBinary(bReader, fileLength);
            }
            bReader.Close();
            return(result);
        }
Exemplo n.º 2
0
        public static Dictionary <int, PackageInfo> LoadPackages(string path)
        {
            Dictionary <int, PackageInfo> result = new Dictionary <int, PackageInfo>();

            BinaryReader bReader = new BinaryReader(new FileStream(path, FileMode.Open), Encoding.ASCII);

            bReader.ReadBytes(38);

            VdfFileNode node = VdfFileNode.LoadFromBinary(bReader);

            while (node != null)
            {
                PackageInfo p = FromVdfNode(node);
                if (p != null)
                {
                    result.Add(p.Id, p);
                }
                bReader.ReadBytes(31);
                node = node = VdfFileNode.LoadFromBinary(bReader);
            }

            bReader.Close();

            return(result);
        }