コード例 #1
0
ファイル: ArchiveOptimizer.cs プロジェクト: rebootus/Esthar
        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);
        }
コード例 #2
0
        public void Update()
        {
            ArchiveInformationAccessor accessor = new ArchiveInformationAccessor(ContentFilePath);

            accessor.Write(this);
        }