Exemple #1
0
        public IBigFileFileInfo[] ReadFileInfos(Stream stream, ref BigFileSegmentHeader segmentHeader, ref BigFileHeaderStruct header)
        {
            if (version == null)
            {
                throw new NullReferenceException("Version cannot be null!");
            }

            log.Info("Reading big file file infos, count: {0}", header.Files);
            BigFileVersions.DebugLogVersion(version, log);

            diag.StartStopwatch();

            IBigFileFileInfo[] infos   = new IBigFileFileInfo[header.Files];
            IBigFileFileInfo   tmpInfo = version.CreateFileInfo();

            int fileOffset = segmentHeader.InfoOffset + header.StructSize;

            log.Debug("File info offset: {0:X8}", fileOffset);
            byte[] buffer = buffers[tmpInfo.StructSize];
            stream.Seek(fileOffset, SeekOrigin.Begin);
            for (int i = 0; i < header.Files; i++)
            {
                stream.Read(buffer, 0, tmpInfo.StructSize);
                infos[i] = tmpInfo.FromBytes(buffer);
                infos[i].DebugLog(log);
            }

            log.Info("File infos read!  Time taken: {0}ms", diag.StopwatchTime);
            log.Info("File count: {0}", header.Files);

            return(infos);
        }
Exemple #2
0
        public IBigFileFolderInfo[] ReadFolderInfos(Stream stream, ref BigFileSegmentHeader segmentHeader, ref BigFileHeaderStruct header)
        {
            if (version == null)
            {
                throw new NullReferenceException("Version cannot be null!");
            }

            log.Info("Reading big file folders, count: {0}", header.Folders);
            BigFileVersions.DebugLogVersion(version, log);

            diag.StartStopwatch();

            IBigFileFolderInfo[] infos   = new IBigFileFolderInfo[header.Folders];
            IBigFileFolderInfo   tmpInfo = version.CreateFolderInfo();

            int folderOffset = BigFileUtil.CalculateFolderOffset(version, ref segmentHeader, ref header);

            byte[] buffer = buffers[tmpInfo.StructSize];
            stream.Seek(folderOffset, SeekOrigin.Begin);
            for (short i = 0; i < header.Folders; i++)
            {
                stream.Read(buffer, 0, tmpInfo.StructSize);
                infos[i] = tmpInfo.FromBytes(buffer);
                infos[i].DebugLog(log);
            }

            log.Info("Folder infos read!  Time taken: {0}ms", diag.StopwatchTime);

            return(infos);
        }