Compare commits

..

12 commits

Author SHA1 Message Date
4115e70d14 Test/fix symlink test/extract in v1 file format
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 4s
2024-09-30 17:53:39 +09:00
dd29550649 Fix v1 archive decompression
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 5s
Previous implementation sent too many bytes to decompressor if size was
less than 1024.
2024-09-30 15:45:48 +09:00
64cfe57724 Remove unnecessary printf used for testing
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 6s
2024-09-30 15:15:00 +09:00
712f2711d7 Impl. extract with decompressor file format v1
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 57s
2024-09-30 14:59:48 +09:00
8e24d4e3d2 v1 extract skip non-specified args if exists 2024-09-30 13:12:39 +09:00
eff2b44f6d Impl. setting stored UID/GID if EUID 0
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 56s
2024-09-28 19:07:37 +09:00
7c4663daf2 "Fix" Linux/Mac/Unix usage 2024-09-28 19:07:37 +09:00
49f6434601 Impl. simple test/extract new file format (WIP)
TODO:
    Extract symlinks in new format (implemented but untested).
    Extract compressed files in new format.
2024-09-28 19:07:37 +09:00
e5acb4d730 Split up handling of archive file based on version 2024-09-28 19:07:37 +09:00
d48d458712 Fix typo 2024-09-28 19:07:37 +09:00
1bbfd8c53d Fix typo in file format specification version 1 2024-09-28 19:07:37 +09:00
b9ed8961a4 Create file format for format version 1
This is in preparation of improving compression by concatenating files
together before compressing them to reduce the per-file overhead.

Discussed in
#18
2024-09-28 19:07:37 +09:00
3 changed files with 6 additions and 32 deletions

View file

@ -67,13 +67,12 @@ int main(int argc, const char **argv) {
}
}
SDArchiverParsedStatus parsed_status;
__attribute__((cleanup(simple_archiver_list_free)))
SDArchiverLinkedList *filenames =
simple_archiver_parsed_to_filenames(&parsed, &parsed_status);
if (!filenames || parsed_status != SDAPS_SUCCESS) {
fprintf(stderr, "ERROR: %s!\n",
simple_archiver_parsed_status_to_str(parsed_status));
simple_archiver_parsed_to_filenames(&parsed);
if (!filenames) {
fprintf(stderr,
"ERROR: Failed to resolve filenames from positional arguments!\n");
return 8;
}

View file

@ -131,17 +131,6 @@ int list_remove_same_str_fn(void *data, void *ud) {
return 0;
}
char *simple_archiver_parsed_status_to_str(SDArchiverParsedStatus status) {
switch (status) {
case SDAPS_SUCCESS:
return "Success";
case SDAPS_NO_USER_CWD:
return "No user current working directory (-C <dir>)";
default:
return "Unknown error";
}
}
void simple_archiver_print_usage(void) {
fprintf(stderr, "Usage flags:\n");
fprintf(stderr, "-c : create archive file\n");
@ -378,7 +367,7 @@ void simple_archiver_free_parsed(SDArchiverParsed *parsed) {
}
SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
const SDArchiverParsed *parsed, SDArchiverParsedStatus *status_out) {
const SDArchiverParsed *parsed) {
SDArchiverLinkedList *files_list = simple_archiver_list_init();
__attribute__((cleanup(simple_archiver_hash_map_free)))
SDArchiverHashMap *hash_map = simple_archiver_hash_map_init();
@ -392,9 +381,6 @@ SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
original_cwd = realpath(".", NULL);
if (chdir(parsed->user_cwd)) {
simple_archiver_list_free(&files_list);
if (status_out) {
*status_out = SDAPS_NO_USER_CWD;
}
return NULL;
}
}
@ -621,8 +607,5 @@ SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
}
}
if (status_out) {
*status_out = SDAPS_SUCCESS;
}
return files_list;
}

View file

@ -59,14 +59,6 @@ typedef struct SDArchiverFileInfo {
char *link_dest;
} SDArchiverFileInfo;
typedef enum SDArchiverParsedStatus {
SDAPS_SUCCESS,
SDAPS_NO_USER_CWD,
} SDArchiverParsedStatus;
/// Returned c-string does not need to be free'd.
char *simple_archiver_parsed_status_to_str(SDArchiverParsedStatus status);
void simple_archiver_print_usage(void);
SDArchiverParsed simple_archiver_create_parsed(void);
@ -82,6 +74,6 @@ void simple_archiver_free_parsed(SDArchiverParsed *parsed);
/// Each entry in the linked list is an SDArchiverFileInfo object.
SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
const SDArchiverParsed *parsed, SDArchiverParsedStatus *status_out);
const SDArchiverParsed *parsed);
#endif