JuliaIO / Tar.jl

TAR files: create, list, extract them in pure Julia
MIT License
79 stars 19 forks source link

Allow early termination after n files have been extracted #134

Open jamesrhester opened 2 years ago

jamesrhester commented 2 years ago

GNU Tar has an --occurrence option which allows tar to terminate early after n occurrences of the file have been extracted. Something similar would be useful for Julia Tar so that time and bytes can be saved when only a part of the archive is needed.

I've tried using the predicate function to recreate this functionality by closing the io stream once the next header after the extracted file is being processed, but the error caused by the premature closing of the stream can lead to the extracted file not being written to disk before everything is torn down (or at least the extracted file is missing, I assume this is the reason).

An alternative solution would be to expose the io stream for the extracted file so that it could be explicitly flushed.