Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void Update()
        {
            ArchiveInformationAccessor accessor = new ArchiveInformationAccessor(ContentFilePath);

            accessor.Write(this);
        }