public ArchiveInformation Optimize() { ArchiveInformation targetInfo; ArchiveAnalizer analizer = new ArchiveAnalizer(_info); analizer.ReadNativeInformation(); using (MemoryMappedFile memoryFile = GetSourceMemoryMappedFile()) { analizer.AnalizeUncompressedArchive(memoryFile); targetInfo = CreateTargetArchiveInformation(); // Правка смещений CorrectOffsets(memoryFile, _info.RootArchive.Childs.OfType <ArchiveArchiveEntry>().ToArray(), targetInfo.RootArchive.Childs.OfType <ArchiveArchiveEntry>().ToArray()); WriteMetrics(targetInfo); using (Stream output = new FileStream(targetInfo.ContentFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) WriteContent(memoryFile, output, _info, targetInfo); } targetInfo.IsOptimized = true; targetInfo.MoveFiles(_info); ArchiveInformationAccessor accessor = new ArchiveInformationAccessor(targetInfo.ContentFilePath); accessor.Write(targetInfo); return(targetInfo); }
public void Update() { ArchiveInformationAccessor accessor = new ArchiveInformationAccessor(ContentFilePath); accessor.Write(this); }