Read the header for a
Entry at the given
TarEntryOffset
in the tar file. The
entryContent will contain the correct
metadata but an empty file content. The
Handle must be open for
reading and be seekable.
The
Handle position is advanced to the beginning of the entry
content (if any). You must check the
entryContent to see if the
entry is of type
NormalFile. If it is, the
NormalFile
gives the content length and you are free to read this much data from
the
Handle.
entry <- Tar.hReadEntryHeader hnd
case Tar.entryContent entry of
Tar.NormalFile _ size -> do content <- BS.hGet hnd size
...
Of course you don't have to read it all in one go (as
hReadEntry does), you can use any appropriate method to read it
incrementally.
In addition to I/O errors, this can throw a
FormatError if the
offset is wrong, or if the file is not valid tar format.
There is also the lower level operation
hSeekEntryOffset.