Comments (4)
The tar data is not fully written until the TarOutputStream
is closed (or when the buffer is flushed, which happens when the entry content is large enough). The .Length
is the number of bytes that have been written to the output stream, which doesn't necessarily correlate to the number of bytes written to it.
Furthermore, if the TarOutputStream does not own the underlying stream, it also works properly.
Yes, that is how you should use this with a memory stream.
The underlying stream is normally closed to avoid leaking stream handles, but if you want to opt out of that you add the IsStreamOwner = false
and take responsibility for disposing of the stream yourself.
from sharpziplib.
The tar data is not fully written until the
TarOutputStream
is closed (or when the buffer is flushed, which happens when the entry content is large enough).
I can not use a closed stream anymore (and for the open stream the data is not flushed). This becomes very difficult and inconvenient when dealing with small tar entries. Using my own stream (where the TarOutputStream
is not the stream owner) can be used as a workaround, but it is inconvenient for developers and they may not even be aware of this requirement in the first place.
from sharpziplib.
I can not use a closed stream anymore (and for the open stream the data is not flushed).
I don't know what you are trying to do, but you cannot create a valid tar file without closing it, since it needs to add the EOF blocks to the end. If you are extending the TarOutputStream
like you are doing in the reproduction code example, then why don't you instead use a TarOutputStream
?
I also don't understand how adding IsStreamOwner = false
and then using the MemoryStream
would be any less convenient. It doesn't matter how large the entries are, after the EOF chunks no new entries can be added, which is why the stream is closed.
Updated .NETFiddle with suggested usage:
https://dotnetfiddle.net/cAH5F2
from sharpziplib.
since it needs to add the EOF blocks to the end.
Yes, you are correct. There is something I overlooked. For some reason, I thought that closing the stream would only add the EOF marker. However, since I need to send the stream to an HTTP endpoint, I cannot simply close it and be finished like I would usually do with a file stream.
I also don't understand how adding
IsStreamOwner = false
and then using theMemoryStream
would be any less convenient.
By finalizing the tar stream (similar to CloseEntry
) while keeping it open, I could save some lines of code. I may have been distracted by noticing that few bytes were neither written nor flushed (without closing it). By the way, that is exactly what I currently do. Thank you for your response and clarification.
from sharpziplib.
Related Issues (20)
- Reading and writing in sync mode problems after update to 1.4 HOT 2
- Unpacking 7z archive failed. HOT 2
- Perf - Add buffer pooling where relevant
- Use CompressionMethod.Stored and flush the ZipOutputStream after each entity was added leads Zip corrupted in SharpZipLib 1.4.2 HOT 9
- Reading deflate file throw "Unexpected EOF" HOT 22
- SharpZipLib v1.4 introduced breaking change
- GetNextEntryAsync might use too large buffer HOT 3
- TAR archive has only 20kb when application high load
- xarchiver can't open tar files created with this library
- Symlink creation not possible with `TarArchive.WriteEntry()`. HOT 1
- .NET Framework 4.6.2 Support?
- Could not load file or assembly 'System.Threading.Tasks.Extensions' or one of its dependencies
- Original DateTime/DosTime value
- TestArchive doesn't handle invalid offsets correctly HOT 2
- It's not possible to tar files starting with "system" in the file name.
- Problem when create zip in network folder
- Add support for .NET Framework 4.6.1 to target frameworks.
- Creating incomplete zip when using zip64.
- Problem reading archives containg Zip64 files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharpziplib.