Beispiel #1
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);
        }
Beispiel #2
0
        public void WriteFolderInfos(ref BigFileSegmentHeader segmentHeader, ref BigFileHeaderStruct header, IBigFileFolderInfo[] infos)
        {
            if (fileInfo == null || !fileInfo.Exists)
            {
                throw new Exception("File info cannot be null!");
            }

            log.Debug("Writing folder infos to file {0}", fileInfo.FullName);

            using (FileStream fs = File.OpenWrite(fileInfo.FullName))
            {
                int folderOffset = BigFileUtil.CalculateFolderOffset(version, ref segmentHeader, ref header);
                fs.Seek(folderOffset, SeekOrigin.Begin);
                WriteFolderInfos(fs, infos);
            }
        }