Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
 private void Init(
     Dictionary <string, Stream> streamDict,
     SevenZipCompressor compressor, UpdateData updateData, bool directoryStructure)
 {
     _streams         = new Stream[streamDict.Count];
     _streamFileInfos = new FileInfo[streamDict.Count];
     streamDict.Values.CopyTo(_streams, 0);
     _entries = new string[streamDict.Count];
     streamDict.Keys.CopyTo(_entries, 0);
     _actualFilesCount = streamDict.Count;
     for (int i = 0; i < _streams.Length; i++)
     {
         var str = _streams[i];
         if (str != null)
         {
             _bytesCount += str.Length;
         }
         var fileStream = str as FileStream;
         if (fileStream != null)
         {
             try
             {
                 var fileInfo = new FileInfo(fileStream.Name);
                 if (fileInfo.Exists)
                 {
                     _streamFileInfos[i] = fileInfo;
                 }
             }
             catch
             {
                 //ignored.
             }
         }
     }
     CommonInit(compressor, updateData, directoryStructure);
 }
Exemplo n.º 3
0
        private void Init(
            FileInfo[] files, string[] altNames, int rootLength, SevenZipCompressor compressor,
            UpdateData updateData, bool directoryStructure)
        {
            _files      = files;
            _rootLength = rootLength;
            _altNames   = altNames;

            if (files != null)
            {
                foreach (var fi in files)
                {
                    if (fi.Exists)
                    {
                        if ((fi.Attributes & FileAttributes.Directory) == 0)
                        {
                            _bytesCount += fi.Length;
                            _actualFilesCount++;
                        }
                    }
                }
            }
            CommonInit(compressor, updateData, directoryStructure);
        }
Exemplo n.º 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="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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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);
 }