Commit Graph

23 Commits

Author SHA1 Message Date
88d6fbffb7
fix: Check for _WIN32 instead of _MSC_VER 2023-02-06 23:17:28 +01:00
8cb5175630
fix: Do not #include <sys/types.h> on Windows
Instead, we provide our own typedef for mode_t, uid_t and gid_t, and we get time_t from <time.h>.
2023-02-05 14:22:31 +01:00
482ac6d949
feat: Add write support
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.
2023-02-04 19:02:08 +01:00
5b0d597c09
feat: Add support for block and character devices 2023-01-29 22:07:54 +01:00
1f08cf4b31
feat: Add support for FIFOs 2023-01-27 23:00:53 +01:00
3772e9e3a6
feat: Add support for hard links 2023-01-27 22:46:18 +01:00
599cac5811
feat: Add support for symbolic links
All the pieces were in place, we just needed to put them together.

Sorry, but sub-500 LoC isn't gonna work anymore...
2023-01-26 22:12:42 +01:00
9a7629459e
chore: Add copyright headers to all source files 2023-01-12 21:04:52 +01:00
27dac123f4
fix: Make minitar_read_contents() take a const pointer to entry 2023-01-12 20:03:42 +01:00
912b98d2d7
fix: Include stddef.h in minitar.h to make sure we have size_t 2023-01-12 20:02:13 +01:00
dead1e3ee2
feat: Move all internal structures to a minitar_entry_internal struct 2023-01-12 19:20:32 +01:00
55276a78e2
Add newlines at EOF so clang doesn't complain 2022-12-31 12:51:47 +01:00
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
577f99cca6 Reorder function declarations in minitar.h 2022-11-30 11:20:36 +01:00
28d1eab1c1 Remove character and block devices from supported entry types
Closes #1.
2022-11-30 11:20:13 +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
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
c8ef43e33b Make it C++-compatible 2022-11-06 12:35:30 +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
6bb0fecdc4 Only define the contents of a struct minitar inside minitar
This structure should be opaque for everyone using the library, and every public API just uses a pointer to it.
2022-11-06 11:04:52 +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