コード例 #1
0
            public ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry, CompressionInfo compressionInfo)
            {
                this.writer = writer;

                this.entry           = entry;
                this.compressionInfo = compressionInfo == null ? writer.zipCompressionInfo : new ZipCompressionInfo(compressionInfo);
                writeStream          = GetWriteStream(originalStream);
            }
コード例 #2
0
ファイル: ZipWriter.cs プロジェクト: zhangf911/NoahGameFrame
 internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry)
 {
     this.writer         = writer;
     this.originalStream = originalStream;
     writeStream         = GetWriteStream(originalStream);
     this.writer         = writer;
     this.entry          = entry;
 }
コード例 #3
0
        public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment, string password = null, Crc32?crc = null, CompressionInfo compressionInfo = null)
        {
            entryPath        = NormalizeFilename(entryPath);
            modificationTime = modificationTime ?? DateTime.Now;
            comment          = comment ?? string.Empty;

            var  explicitPassword = password ?? this.password;
            bool doEncryption     = !String.IsNullOrEmpty(explicitPassword);

            var entry = new ZipCentralDirectoryEntry()
            {
                Comment          = comment,
                FileName         = entryPath,
                ModificationTime = modificationTime,
                HeaderOffset     = (uint)streamPosition,
                IsEncrypted      = doEncryption
            };

            var headersize = (uint)WriteHeader(entryPath, modificationTime, doEncryption, compressionInfo);

            Stream outputStream;

            if (doEncryption)
            {
                byte[] encryptionHeader;
                PkwareTraditionalEncryptionData pkwareTraditionalEncryptionData;
                if (OutputStream.CanSeek)
                {
                    if (crc.HasValue)
                    {
                        pkwareTraditionalEncryptionData = PkwareTraditionalEncryptionData.ForWrite(explicitPassword, (uint)(int)crc, out encryptionHeader);
                    }
                    else
                    {
                        throw new ArgumentNullException(nameof(crc), "Crc32 must be provided when password is set and target archive stream supports seeking");
                    }
                }
                else
                {
                    pkwareTraditionalEncryptionData = PkwareTraditionalEncryptionData.ForWrite(explicitPassword, modificationTime, out encryptionHeader);
                }
                OutputStream.Write(encryptionHeader, 0, encryptionHeader.Length);
                entry.Compressed += (uint)encryptionHeader.Length;
                outputStream      = new PkwareTraditionalCryptoStream(OutputStream, pkwareTraditionalEncryptionData, CryptoMode.Encrypt);
            }
            else
            {
                outputStream = OutputStream;
            }

            streamPosition += headersize;
            return(new ZipWritingStream(this, outputStream, entry, compressionInfo));
        }
コード例 #4
0
ファイル: ZipWriter.cs プロジェクト: RainsSoft/sharpcompress
 public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment,  CompressionInfo compressionInfo)
 {
     entryPath = this.NormalizeFilename(entryPath);
     DateTime? nullable = modificationTime;
     modificationTime = new DateTime?(nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.Now);
     comment = comment ?? "";
     ZipCentralDirectoryEntry entry2 = new ZipCentralDirectoryEntry();
     entry2.Comment = comment;
     entry2.FileName = entryPath;
     entry2.ModificationTime = modificationTime;
     entry2.HeaderOffset = (uint) this.streamPosition;
     ZipCentralDirectoryEntry entry = entry2;
     uint num = (uint) this.WriteHeader(entryPath, modificationTime, compressionInfo);
     this.streamPosition += num;
     return new ZipWritingStream(this, base.OutputStream, entry);
 }
コード例 #5
0
ファイル: ZipWriter.cs プロジェクト: zhangf911/NoahGameFrame
        public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment)
        {
            entryPath        = NormalizeFilename(entryPath);
            modificationTime = modificationTime ?? DateTime.Now;
            comment          = comment ?? "";
            var entry = new ZipCentralDirectoryEntry
            {
                Comment          = comment,
                FileName         = entryPath,
                ModificationTime = modificationTime,
                HeaderOffset     = (uint)streamPosition,
            };
            var headersize = (uint)WriteHeader(entryPath, modificationTime);

            streamPosition += headersize;
            return(new ZipWritingStream(this, OutputStream, entry));
        }
コード例 #6
0
ファイル: ZipWriter.cs プロジェクト: eklann/sharpcompress
        public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment, CompressionInfo compressionInfo = null)
        {
            entryPath = NormalizeFilename(entryPath);
            modificationTime = modificationTime ?? DateTime.Now;
            comment = comment ?? "";
            var entry = new ZipCentralDirectoryEntry
                            {
                                Comment = comment,
                                FileName = entryPath,
                                ModificationTime = modificationTime,
                                HeaderOffset = (uint) streamPosition,
                            };

            var headersize = (uint)WriteHeader(entryPath, modificationTime, compressionInfo);
            streamPosition += headersize;
            return new ZipWritingStream(this, OutputStream, entry, compressionInfo);
        }
コード例 #7
0
ファイル: ZipWriter.cs プロジェクト: RainsSoft/sharpcompress
        public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment, CompressionInfo compressionInfo)
        {
            entryPath = this.NormalizeFilename(entryPath);
            DateTime?nullable = modificationTime;

            modificationTime = new DateTime?(nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.Now);
            comment          = comment ?? "";
            ZipCentralDirectoryEntry entry2 = new ZipCentralDirectoryEntry();

            entry2.Comment          = comment;
            entry2.FileName         = entryPath;
            entry2.ModificationTime = modificationTime;
            entry2.HeaderOffset     = (uint)this.streamPosition;
            ZipCentralDirectoryEntry entry = entry2;
            uint num = (uint)this.WriteHeader(entryPath, modificationTime, compressionInfo);

            this.streamPosition += num;
            return(new ZipWritingStream(this, base.OutputStream, entry));
        }
コード例 #8
0
ファイル: ZipWriter.cs プロジェクト: eklann/sharpcompress
 internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry, CompressionInfo compressionInfo)
 {
     this.writer = writer;
     this.originalStream = originalStream;
     this.writer = writer;
     this.entry = entry;
     this.compressionInfo = compressionInfo == null ? writer.zipCompressionInfo : new ZipCompressionInfo(compressionInfo);
     writeStream = GetWriteStream(originalStream);
 }
コード例 #9
0
ファイル: ZipWriter.cs プロジェクト: yaozd/sharpcompress
 internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry)
 {
     this.writer = writer;
     this.originalStream = originalStream;
     writeStream = GetWriteStream(originalStream);
     this.writer = writer;
     this.entry = entry;
 }