whether&when to dispose OutputStream #91

Closed
opened 2026-01-29 22:06:27 +00:00 by claunia · 3 comments
Owner

Originally created by @Supegg on GitHub (Mar 3, 2016).

i think the caller decides whether&when to dispose outputstream.
so, i suggest
public TarWriter(Stream destination, CompressionInfo compressionInfo, bool closeStream = true)
: base(ArchiveType.Tar)
public GZipWriter(Stream destination, bool closeStream = true)
: base(ArchiveType.GZip)
public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment, bool closeStream = true)
: base(ArchiveType.Zip)

PS: why? OutputStream.Dispose(); // required when bzip2 compression is used

Originally created by @Supegg on GitHub (Mar 3, 2016). i think the caller decides whether&when to dispose outputstream. so, i suggest public TarWriter(Stream destination, CompressionInfo compressionInfo, bool closeStream = true) : base(ArchiveType.Tar) public GZipWriter(Stream destination, bool closeStream = true) : base(ArchiveType.GZip) public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment, bool closeStream = true) : base(ArchiveType.Zip) PS: why? OutputStream.Dispose(); // required when bzip2 compression is used
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2016):

You're saying you want the option for sharpcompress to close the stream for you?

@adamhathcock commented on GitHub (Mar 30, 2016): You're saying you want the option for sharpcompress to close the stream for you?
Author
Owner

@Supegg commented on GitHub (Mar 31, 2016):

when destination is a filestream, it is ok.
Sometimes destination is a MemoryStream, it will pass to a method for use. If closed after tar, it doesn't work.

@Supegg commented on GitHub (Mar 31, 2016): when destination is a filestream, it is ok. Sometimes destination is a MemoryStream, it will pass to a method for use. If closed after tar, it doesn't work.
Author
Owner

@adamhathcock commented on GitHub (Mar 31, 2016):

You're right. I'm fixing this now: https://github.com/adamhathcock/sharpcompress/pull/138

@adamhathcock commented on GitHub (Mar 31, 2016): You're right. I'm fixing this now: https://github.com/adamhathcock/sharpcompress/pull/138
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#91