Compare commits
No commits in common. "735d2b4f7a0a00d465bfba956b8561638d5c5a05" and "0a6afe6148b3e7f8760c7f7e8c7d3c8e502d3e43" have entirely different histories.
735d2b4f7a
...
0a6afe6148
3 changed files with 6 additions and 35 deletions
|
@ -22,8 +22,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "data_structures/linked_list.h"
|
||||
#include "parser.h"
|
||||
#include "platforms.h"
|
||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||
|
@ -36,7 +34,6 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "data_structures/hash_map.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#define TEMP_FILENAME_CMP "simple_archiver_compressed_%u.tmp"
|
||||
|
@ -506,9 +503,6 @@ int write_files_fn(void *data, void *ud) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_nop_fn(__attribute__((unused)) void *unused) {}
|
||||
void cleanup_free_fn(void *data) { free(data); }
|
||||
|
||||
char *simple_archiver_error_to_string(enum SDArchiverStateReturns error) {
|
||||
switch (error) {
|
||||
case SDAS_SUCCESS:
|
||||
|
@ -736,20 +730,6 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
|
||||
uint32_t size = u32;
|
||||
int skip = 0;
|
||||
__attribute__((cleanup(simple_archiver_hash_map_free)))
|
||||
SDArchiverHashMap *hash_map = NULL;
|
||||
if (state->parsed->working_files && state->parsed->working_files[0] != NULL) {
|
||||
hash_map = simple_archiver_hash_map_init();
|
||||
for (char **iter = state->parsed->working_files; *iter != NULL; ++iter) {
|
||||
int len = strlen(*iter) + 1;
|
||||
char *key = malloc(len);
|
||||
memcpy(key, *iter, len);
|
||||
key[len - 1] = 0;
|
||||
simple_archiver_hash_map_insert(&hash_map, key, key, len, cleanup_nop_fn,
|
||||
cleanup_free_fn);
|
||||
// fprintf(stderr, "\"%s\" put in map\n", key);
|
||||
}
|
||||
}
|
||||
for (uint32_t idx = 0; idx < size; ++idx) {
|
||||
fprintf(stderr, "\nFile %10u of %10u.\n", idx + 1, size);
|
||||
if (feof(in_f) || ferror(in_f)) {
|
||||
|
@ -782,6 +762,8 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
skip = 0;
|
||||
}
|
||||
if (!skip) {
|
||||
simple_archiver_helper_make_dirs((const char *)buf);
|
||||
out_f = fopen((const char *)buf, "wb");
|
||||
out_f_name = malloc(strlen((const char *)buf) + 1);
|
||||
memcpy(out_f_name, buf, strlen((const char *)buf) + 1);
|
||||
}
|
||||
|
@ -811,6 +793,8 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
skip = 0;
|
||||
}
|
||||
if (!skip) {
|
||||
simple_archiver_helper_make_dirs((const char *)uc_heap_buf);
|
||||
out_f = fopen((const char *)buf, "wb");
|
||||
out_f_name = malloc(strlen((const char *)buf) + 1);
|
||||
memcpy(out_f_name, buf, strlen((const char *)buf) + 1);
|
||||
}
|
||||
|
@ -868,20 +852,9 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
fprintf(stderr, " File size: %lu\n", u64);
|
||||
}
|
||||
|
||||
int skip_due_to_map = 0;
|
||||
if (hash_map != NULL && out_f_name) {
|
||||
if (simple_archiver_hash_map_get(hash_map, out_f_name,
|
||||
strlen(out_f_name) + 1) == NULL) {
|
||||
skip_due_to_map = 1;
|
||||
fprintf(stderr, "Skipping not specified in args...\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (do_extract && !skip && !skip_due_to_map) {
|
||||
if (do_extract && !skip) {
|
||||
fprintf(stderr, " Extracting...\n");
|
||||
|
||||
simple_archiver_helper_make_dirs((const char *)out_f_name);
|
||||
out_f = fopen(out_f_name, "wb");
|
||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
||||
|
|
|
@ -37,8 +37,6 @@ void simple_archiver_hash_map_free(SDArchiverHashMap **hash_map);
|
|||
/// key must remain valid for the lifetime of its entry in the hash map.
|
||||
/// If value_cleanup_fn is NULL, then "free" is used instead.
|
||||
/// If key_cleanup_fn is NULL, then "free" is used instead.
|
||||
/// NOTICE: You must not pass NULL to value, otherwise all "get" checks will
|
||||
/// fail for the inserted key.
|
||||
int simple_archiver_hash_map_insert(SDArchiverHashMap **hash_map, void *value,
|
||||
void *key, unsigned int key_size,
|
||||
void (*value_cleanup_fn)(void *),
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct SDArchiverParsed {
|
|||
char *decompressor;
|
||||
/// Null-terminated strings in array of strings.
|
||||
/// Last entry should be NULL.
|
||||
/// Determines a "white-list" of files to extract when extracting.
|
||||
/// Not used when extracting.
|
||||
char **working_files;
|
||||
} SDArchiverParsed;
|
||||
|
||||
|
|
Loading…
Reference in a new issue