Esempio n. 1
0
        protected override void OnOpen(EndianBinaryReader reader)
        {
            MagicNumber         = Encoding.ASCII.GetString(reader.ReadBytes(4));
            ArchiveSize         = reader.ReadUInt32();
            NumFileTypes        = reader.ReadUInt16();
            NumFiles            = reader.ReadUInt16();
            FileTypesOffset     = reader.ReadUInt32();
            FileInfoIndexOffset = reader.ReadUInt32();
            FileIndexOffset     = reader.ReadUInt32();
            CodenameString      = Encoding.ASCII.GetString(reader.ReadBytes(8)).TrimEnd('\0');

            reader.BaseStream.Seek(FileTypesOffset, SeekOrigin.Begin);
            FileTypes = new GARv5FileType[NumFileTypes];
            for (int i = 0; i < FileTypes.Length; i++)
            {
                FileTypes[i] = new GARv5FileType(reader);
            }

            reader.BaseStream.Seek(FileInfoIndexOffset, SeekOrigin.Begin);
            FileInfos = new GARv5FileInfo[NumFiles];
            for (int i = 0; i < FileInfos.Length; i++)
            {
                FileInfos[i] = new GARv5FileInfo(reader);
            }
        }
Esempio n. 2
0
        protected override void OnOpen(EndianBinaryReader reader)
        {
            MagicNumber         = Encoding.ASCII.GetString(reader.ReadBytes(4));
            ArchiveSize         = reader.ReadUInt32();
            NumFileTypes        = reader.ReadUInt16();
            NumFiles            = reader.ReadUInt16();
            FileTypesOffset     = reader.ReadUInt32();
            FileInfoIndexOffset = reader.ReadUInt32();
            FileIndexOffset     = reader.ReadUInt32();
            CodenameString      = Encoding.ASCII.GetString(reader.ReadBytes(8)).TrimEnd('\0');

            reader.BaseStream.Seek(FileTypesOffset, SeekOrigin.Begin);
            FileTypes = new GARv5FileType[NumFileTypes];
            for (int i = 0; i < FileTypes.Length; i++)
            {
                FileTypes[i] = new GARv5FileType(reader);
            }

            reader.BaseStream.Seek(FileInfoIndexOffset, SeekOrigin.Begin);
            FileInfos = new GARv5FileInfo[NumFiles];
            for (int i = 0; i < FileInfos.Length; i++)
            {
                FileInfos[i] = new GARv5FileInfo(reader);
            }

            for (int i = 0; i < FileInfos.Length; i++)
            {
                GARv5FileInfo file = FileInfos[i];
                GARv5FileType type = FileTypes.FirstOrDefault(x => (i >= x.FirstFileOfType && i < (x.FirstFileOfType + x.NumFilesOfType)));

                string filename = (Path.GetExtension(file.Filename) != string.Empty ? file.Filename : $"{file.Filename}.{type.FileExtension}");
                string root     = Path.GetPathRoot(file.Filename);

                if (root != string.Empty)
                {
                    file.CombinedPath = Path.Combine(root.Replace(":", string.Empty), filename.Replace(root, string.Empty));
                }
                else
                {
                    file.CombinedPath = filename;
                }
            }
        }