Beispiel #1
0
 public static void Write(string steamShortcutFilePath, BVPropertyCollection data)
 {
     using (FileStream stream = File.OpenWrite(steamShortcutFilePath))
         using (BinaryWriter writer = new BinaryWriter(stream))
         {
             BVdfFile.WritePropertyArray(writer, data);
             writer.Write((byte)0x08);
         }
 }
Beispiel #2
0
        public static SteamAppInfoDataFile Read(string steamShortcutFilePath)
        {
            using (FileStream stream = File.OpenRead(steamShortcutFilePath))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    List <SteamAppInfoDataFileChunk> Chunks = new List <SteamAppInfoDataFileChunk>();
                    byte   Version1 = reader.ReadByte();
                    UInt16 Type     = reader.ReadUInt16();
                    byte   Version2 = reader.ReadByte();
                    UInt32 Version3 = reader.ReadUInt32();
                    //while(reader.BaseStream.Position < reader.BaseStream.Length)
                    for (;;)
                    {
                        UInt32 AppID = reader.ReadUInt32();
                        if (AppID == 0)
                        {
                            break;
                        }
                        UInt32 DataSize = reader.ReadUInt32();
                        long   startPos = reader.BaseStream.Position;
                        //Console.WriteLine($"Expected End Position: {(startPos + DataSize):X8}");

                        UInt32 State            = reader.ReadUInt32();
                        UInt32 LastUpdate       = reader.ReadUInt32();
                        UInt64 AccessToken      = reader.ReadUInt64();
                        byte[] Checksum         = reader.ReadBytes(20);
                        UInt32 LastChangeNumber = reader.ReadUInt32();

                        BVPropertyCollection Data = BVdfFile.ReadPropertyArray(reader);
                        //long endPos = reader.BaseStream.Position;
                        if (reader.BaseStream.Position != (startPos + DataSize))
                        {
                            Console.WriteLine("appinfo.vdf chunk data size wrong, adjusting stream position");
                            reader.BaseStream.Seek(startPos + DataSize, SeekOrigin.Begin);
                        }
                        //Console.WriteLine($"*Expected End Position: {(startPos + DataSize):X8}");
                        //Console.WriteLine($"End Position: {(endPos):X8}");

                        SteamAppInfoDataFileChunk Chunk = new SteamAppInfoDataFileChunk(AppID, State, LastUpdate, AccessToken, Checksum, LastChangeNumber, Data);
                        Chunks.Add(Chunk);
                    }
                    return(new SteamAppInfoDataFile(Version1, Type, Version2, Version3, Chunks));
                }
        }