protected override bool delete(string type, Stream stream, Func <string, bool> filter) { OutArchiveFormat archiveFormat = SevenZipWrapper.getArchiveFormat("abc" + type); Dictionary <int, string> fileDictionary = new Dictionary <int, string>(); foreach (var foundItem in lookup(getExtractor(stream, null), filter)) { fileDictionary.Add(foundItem.Value1, null); } if (fileDictionary.Count > 0) { string tempFile; using (var tempStream = TempStreamUtils.NewTempStream(out tempFile, "tmp")) StreamUtils.CopyStream(stream, tempStream, true, true, false); Delete(archiveFormat, tempFile, filter); using (var tempStream = new FileStream(tempFile, FileMode.Open)) StreamUtils.CopyStream(tempStream, stream, false, true, true); //SevenZipSharp crash when compressor.ModifyArchive() is used, //if Compression mode is Append (Create is fine). //lock (_lockObject) //{ // SevenZipCompressor compressor = getCompressor(archiveFormat); // compressor.ModifyArchive(archivePath, fileDictionary); //} } return(true); }
public void CompressMultiple(string archivePath, Dictionary <string, Stream> streamDic, IProgress <FileExplorer.Defines.ProgressEventArgs> progress = null) { OutArchiveFormat archiveFormat = SevenZipWrapper.getArchiveFormat(archivePath); Delete(archiveFormat, archivePath, p => streamDic.Keys.Contains(p)); SevenZipCompressor compressor = getCompressor(archiveFormat, null, progress); compressor.CompressStreamDictionary(streamDic, archivePath); }
public void Modify(string archivePath, string orginalPath, string destName, bool isFolder, IProgress <FileExplorer.Defines.ProgressEventArgs> progress = null) { OutArchiveFormat archiveFormat = SevenZipWrapper.getArchiveFormat(archivePath); string srcParentPath = FileExplorer.Models.PathHelper.Disk.GetDirectoryName(orginalPath); string destPath = FileExplorer.Models.PathHelper.Disk.Combine(srcParentPath, destName); orginalPath = orginalPath.TrimEnd('\\'); var dic = lookup(getExtractor(archivePath), isFolder ? orginalPath + "\\*" : orginalPath).ToDictionary(tup => tup.Value1, tup => FileExplorer.Models.PathHelper.Disk.Combine(destPath, tup.Value2.Substring(orginalPath.Length))); if (dic.Count() > 0) { SevenZipCompressor compressor = getCompressor(archiveFormat, null, progress); compressor.ModifyArchive(archivePath, dic); } }
public override byte[] GetEmptyArchiveBytes(string type) { return(SevenZipWrapper.GetArchiveBytes(type)); }