23 Commits

Author SHA1 Message Date
7d4e774cf7
Rewrite the entire API just to eliminate heap allocations
Just bumping minor because nobody uses this and I don't want to jump up to 2.0.0
2022-12-25 14:33:47 +01:00
e922cfe8b9 read_contents(): shortcircuit if an entry is empty 2022-11-30 10:36:19 +01:00
f156f8472e attempt_read_entry -> try_to_read_valid_entry 2022-11-23 20:56:57 +01:00
cdf1e0bcba Make minitar_read_contents cleaner 2022-11-23 20:56:08 +01:00
408342cb1d Remove shadow function 2022-11-23 20:41:44 +01:00
9420107a55 More commenting 2022-11-23 20:40:47 +01:00
9fe8159d5a More commenting + minitar_get_size_in_blocks -> minitar_align_up_to_block_size 2022-11-23 20:39:34 +01:00
f929a860c4 Be more explicit about "what" is necessary to read the file properly 2022-11-23 18:32:42 +01:00
fd85cf1c6a Full path is now metadata->path and basename metadata->name
Shouldn't have rushed to 1.0.0 so quickly. Oh well, I guess I can allow 1.1.0...
2022-11-23 18:32:10 +01:00
b7c27a25a6 Reorganize minitar_attempt_read_entry 2022-11-22 17:28:34 +01:00
ba7b77bdae Rename internal function minitar_parse_tar_header -> minitar_parse_metadata_from_tar_header 2022-11-22 17:28:15 +01:00
0fbcdde399 Return fclose's status code 2022-11-22 17:25:17 +01:00
d123c49946 Do not automatically read an entry's contents, leave it up to the user
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 :)
2022-11-21 20:20:37 +01:00
2aed955e94 Use const pointers when possible 2022-11-21 17:38:08 +01:00
df26e6d772 Rename minitar_read_file to minitar_read_file_contents 2022-11-06 14:23:35 +01:00
97da894c0f Make naming consistent across all files 2022-11-06 14:21:32 +01:00
a3d3cddeb3 Add functions to search for specific files or file types 2022-11-06 11:51:03 +01:00
8507f57bc1 Add minitar_rewind() 2022-11-06 11:22:27 +01:00
6c916ad861 Add .clang-format 2022-11-06 11:02:26 +01:00
6e0b65aaa8 Open the tar archive in binary mode, for systems that require it 2022-11-06 10:37:09 +01:00
baf8318c29 Read file contents and store them in entry->ptr 2022-11-06 10:33:37 +01:00
0952af15b4 Basic file listing :) 2022-11-05 20:10:48 +01:00
61b122fcf5 Initial groundwork 2022-11-05 18:52:51 +01:00