예제 #1
0
 private void Init(
     Dictionary<string, Stream> streamDict,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     _streams = new Stream[streamDict.Count];
     streamDict.Values.CopyTo(_streams, 0);
     _entries = new string[streamDict.Count];
     streamDict.Keys.CopyTo(_entries, 0);
     _actualFilesCount = streamDict.Count;
     foreach (Stream str in _streams)
     {
         if (str != null)
         {
             _bytesCount += str.Length;
         }
     }
     CommonInit(compressor, updateData, directoryStructure);
 }
예제 #2
0
 private void Init(
     FileInfo[] files, int rootLength, SevenZipCompressor compressor,
     UpdateData updateData, bool directoryStructure)
 {
     _files = files;
     _rootLength = rootLength;
     if (files != null)
     {
         foreach (var fi in files)
         {
             if (fi.Exists)
             {
                 _bytesCount += fi.Length;
                 if ((fi.Attributes & FileAttributes.Directory) == 0)
                 {
                     _actualFilesCount++;
                 }
             }
         }
     }
     CommonInit(compressor, updateData, directoryStructure);
 }
예제 #3
0
 private void Init(
     Stream stream, SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     _fileStream = new InStreamWrapper(stream, false);
     _fileStream.BytesRead += IntEventArgsHandler;
     _actualFilesCount = 1;
     try
     {
         _bytesCount = stream.Length;
     }
     catch (NotSupportedException)
     {
         _bytesCount = -1;
     }
     try
     {
         stream.Seek(0, SeekOrigin.Begin);
     }
     catch (NotSupportedException)
     {
         _bytesCount = -1;
     }
     CommonInit(compressor, updateData, directoryStructure);
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="streamDict">Dictionary&lt;file stream, name of the archive entry&gt;</param>
 /// <param name="password">The archive password</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     Dictionary<string, Stream> streamDict, string password,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
     : base(password)
 {
     Init(streamDict, compressor, updateData, directoryStructure);
 }
예제 #5
0
 private void CommonInit(SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     _compressor = compressor;
     _indexInArchive = updateData.FilesCount;
     _indexOffset = updateData.Mode != InternalCompressionMode.Append ? 0 : _indexInArchive;
     if (_compressor.ArchiveFormat == OutArchiveFormat.Zip)
     {
         _wrappersToDispose = new List<InStreamWrapper>();
     }
     _updateData = updateData;
     _directoryStructure = directoryStructure;
     DefaultItemName = "default";            
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="stream">The input stream</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     Stream stream, SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     Init(stream, compressor, updateData, directoryStructure);
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="stream">The input stream</param>
 /// <param name="password">The archive password</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     Stream stream, string password, SevenZipCompressor compressor, UpdateData updateData,
     bool directoryStructure)
     : base(password)
 {
     Init(stream, compressor, updateData, directoryStructure);
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="files">Array of files to pack</param>
 /// <param name="rootLength">Common file names root length</param>
 /// <param name="password">The archive password</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     FileInfo[] files, int rootLength, string password,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
     : base(password)
 {
     Init(files, rootLength, compressor, updateData, directoryStructure);
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="streamDict">Dictionary&lt;file stream, name of the archive entry&gt;</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     Dictionary <string, Stream> streamDict,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     Init(streamDict, compressor, updateData, directoryStructure);
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="stream">The input stream</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     Stream stream, SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     Init(stream, compressor, updateData, directoryStructure);
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the ArchiveUpdateCallback class
 /// </summary>
 /// <param name="files">Array of files to pack</param>
 /// <param name="rootLength">Common file names root length</param>
 /// <param name="compressor">The owner of the callback</param>
 /// <param name="updateData">The compression parameters.</param>
 /// <param name="directoryStructure">Preserve directory structure.</param>
 public ArchiveUpdateCallback(
     FileInfo[] files, int rootLength,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     Init(files, rootLength, compressor, updateData, directoryStructure);
 }
예제 #12
0
 private static bool CompressionBenchmark(Stream inStream, Stream outStream,
     OutArchiveFormat format, CompressionMethod method,
     ref LibraryFeature? features, LibraryFeature testedFeature)
 {
     try
     {
         var compr = new SevenZipCompressor {ArchiveFormat = format, CompressionMethod = method};
         compr.CompressStream(inStream, outStream);
     }
     catch (Exception)
     {
         return false;
     }
     features |= testedFeature;
     return true;
 }