Sure, 256 characters might fit in 'path', but because of the way
paths are stored in a tar archive, basenames cannot exceed 100
characters. So, adding space for a null-terminator, this reduces
our 'name' field from 128 bytes to 101.
This change is backwards-compatible since any reasonable application
should not depend on the name field being 128 bytes (this was never
mentioned in any documentation, API.md describes it as 'char[]' without
a fixed length). sizeof(metadata.name) should always be used instead.
This uses a new struct (struct minitar_w).
This struct is initialized using the minitar_open_w function, and deleted using minitar_close_w.
The functions to write to an archive are minitar_write_file_entry() and minitar_write_special_entry().
The difference is that regular files have content, while the rest (special entries) do not.
This commit also adds a new example program (pack), which can create tar archives from files (no directory support though).
Archives created using pack and minitar can be read and extracted using GNU tar!!
Documentation is coming in another commit.
This API change modifies minitar_read_entry to skip over the file's contents and instead store the current read position in the entry.
struct minitar_entry no longer has a ptr field, but has a position field (of type fpos_t) for internal use.
minitar_free_entry no longer frees entry->ptr.
A new function has been added, minitar_read_contents().
It reads a certain number of bytes from an entry (which is capped to the entry's size) into a user-provided buffer.
This function can be called at any time provided it is called with a valid archive stream and entry.
This is achieved by calling fgetpos() to store the start of the entry's contents in the entry's position field while reading it.
Then minitar_read_contents() will store the current position, rewind to the entry's position, read the chosen number of bytes from the archive, and then rewind back to the current position.
Since this is a breaking change, it needs a major version bump. Since there was no version, I bumped it to 1.0.0 :)