public static PfsHeader ReadFromStream(System.IO.Stream s) { var start = s.Position; var hdr = new PfsHeader { Version = s.ReadInt64LE(), Magic = s.ReadInt64LE(), Id = s.ReadInt64LE(), Fmode = s.ReadUInt8(), Clean = s.ReadUInt8(), ReadOnly = s.ReadUInt8(), Rsv = s.ReadUInt8(), Mode = (PfsMode)s.ReadUInt16LE(), Unk1 = s.ReadUInt16LE(), BlockSize = s.ReadUInt32LE(), NBackup = s.ReadUInt32LE(), NBlock = s.ReadInt64LE(), DinodeCount = s.ReadInt64LE(), Ndblock = s.ReadInt64LE(), DinodeBlockCount = s.ReadInt64LE(), InodeBlockSig = DinodeS64.ReadFromStream(s) }; s.Position = start + 0x370; hdr.Seed = s.ReadBytes(16); return(hdr); }
public static PfsHeader ReadFromStream(System.IO.Stream s) { var start = s.Position; var hdr = new PfsHeader { Version = s.ReadInt64LE(), Magic = s.ReadInt64LE(), Id = s.ReadInt64LE(), Fmode = s.ReadUInt8(), Clean = s.ReadUInt8(), ReadOnly = s.ReadUInt8(), Rsv = s.ReadUInt8(), Mode = (PfsMode)s.ReadUInt16LE(), Unk1 = s.ReadUInt16LE(), BlockSize = s.ReadUInt32LE(), NBackup = s.ReadUInt32LE(), NBlock = s.ReadInt64LE(), DinodeCount = s.ReadInt64LE(), Ndblock = s.ReadInt64LE(), DinodeBlockCount = s.ReadInt64LE(), }; s.Position += 8; // skip a 64-bit zero hdr.InodeBlockSig = DinodeS64.ReadFromStream(s); if (hdr.Version != 1 || hdr.Magic != 20130315) { throw new InvalidDataException($"Invalid PFS superblock version ({hdr.Version}) or magic ({hdr.Magic})"); } s.Position = start + 0x370; hdr.Seed = s.ReadBytes(16); return(hdr); }