Exemple #1
0
        public static async Task <BSA105Header> ReadHeader(Stream stream)
        {
            stream.Seek(0, SeekOrigin.Begin);
            var headerBytes = new byte[BSA105Header.HeaderSize];
            await stream.ReadAsync(headerBytes, 0, headerBytes.Length);

            return(BSA105Header.Parse(headerBytes, 0));
        }
Exemple #2
0
        public static async Task <List <string> > ReadFileNameBlock(Stream stream, BSA105Header headers)
        {
            stream.Seek(
                (
                    BSA105Header.HeaderSize +
                    (BSA105FolderRecord.FolderRecordSize * headers.FolderCount) +
                    (FileRecord.ByteSize * headers.FileCount) +
                    (headers.TotalFolderNameLength + headers.FolderCount)
                ),
                SeekOrigin.Begin
                );
            var blockBytes = new byte[headers.TotalFileNameLength];
            await stream.ReadAsync(blockBytes, 0, blockBytes.Length);

            var blockString = Encoding.UTF8.GetString(blockBytes);

            return(blockString.Split('\0').ToList());
        }
Exemple #3
0
        public static async Task <FileRecordBlock> ReadFileRecordBlock(Stream stream, BSA105Header header, BSA105FolderRecord folder)
        {
            stream.Seek(folder.FileRecordOffset - header.TotalFileNameLength, SeekOrigin.Begin);

            var nameLength = stream.ReadByte();
            var blockBytes = new byte[nameLength + 1 + (folder.FileCount * FileRecord.ByteSize)];
            await stream.ReadAsync(blockBytes, 1, blockBytes.Length - 1);

            blockBytes[0] = (byte)nameLength;

            return(FileRecordBlock.Parse(blockBytes, 0, (int)folder.FileCount));
        }
Exemple #4
0
        public static async Task <List <BSA105FolderRecord> > ReadFolderRecords(Stream stream, BSA105Header header)
        {
            stream.Seek(BSA105Header.HeaderSize, SeekOrigin.Begin);

            var recordBytes = new byte[BSA105FolderRecord.FolderRecordSize * header.FolderCount];
            var records     = new List <BSA105FolderRecord>((int)header.FolderCount);
            await stream.ReadAsync(recordBytes, 0, recordBytes.Length);

            for (int i = 0; i < header.FolderCount; i++)
            {
                var record = BSA105FolderRecord.Parse(recordBytes, i * BSA105FolderRecord.FolderRecordSize);
                records.Add(record);
            }

            return(records);
        }