rxi/microtar

An empty archive can be written but not read back

guban opened this issue · 0 comments

guban commented

Steps:

  1. Write zero files to an archive. The archive file is created successfully.
  2. Use mtar_open() to read the archive file.

Expected result: mtar_open() succeeds.
Actual result: mtar_open() fails with the "null record" error.

After writing N files into an archive (where N can possibly be zero), one would expect to read that archive and extract N files from it without a failure. Presently, when reading an archive, one has to check whether the tar file is empty (i.e., the file is 1KB of zeros, which is the end-of-archive entry). It would be nice if mtar_open() could handle this special case without failing.