Compare commits
2 commits
d8068a6f5f
...
852c931d8b
Author | SHA1 | Date | |
---|---|---|---|
852c931d8b | |||
55cd3b2659 |
2 changed files with 19 additions and 5 deletions
|
@ -104,6 +104,9 @@ void cleanup_temp_filename_delete(void ***ptrs_array) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *filename_to_absolute_path(const char *filename) {
|
char *filename_to_absolute_path(const char *filename) {
|
||||||
|
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
||||||
__attribute__((cleanup(free_malloced_memory))) void *path =
|
__attribute__((cleanup(free_malloced_memory))) void *path =
|
||||||
malloc(strlen(filename) + 1);
|
malloc(strlen(filename) + 1);
|
||||||
strncpy(path, filename, strlen(filename) + 1);
|
strncpy(path, filename, strlen(filename) + 1);
|
||||||
|
@ -138,6 +141,8 @@ char *filename_to_absolute_path(const char *filename) {
|
||||||
strlen(filename_basename) + 1);
|
strlen(filename_basename) + 1);
|
||||||
|
|
||||||
return fullpath;
|
return fullpath;
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_files_fn(void *data, void *ud) {
|
int write_files_fn(void *data, void *ud) {
|
||||||
|
@ -707,8 +712,12 @@ int write_files_fn(void *data, void *ud) {
|
||||||
|
|
||||||
// Need to get abs_path for checking/setting a flag before storing flags.
|
// Need to get abs_path for checking/setting a flag before storing flags.
|
||||||
// Get absolute path.
|
// Get absolute path.
|
||||||
__attribute__((cleanup(free_malloced_memory))) void *abs_path =
|
__attribute__((cleanup(free_malloced_memory))) void *abs_path = NULL;
|
||||||
realpath(file_info->filename, NULL);
|
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
||||||
|
abs_path = realpath(file_info->filename, NULL);
|
||||||
|
#endif
|
||||||
__attribute__((cleanup(free_malloced_memory))) void *rel_path = NULL;
|
__attribute__((cleanup(free_malloced_memory))) void *rel_path = NULL;
|
||||||
if (abs_path) {
|
if (abs_path) {
|
||||||
// Get relative path.
|
// Get relative path.
|
||||||
|
@ -873,8 +882,12 @@ int filenames_to_abs_map_fn(void *data, void *ud) {
|
||||||
|
|
||||||
// Try putting all parent dirs up to current working directory.
|
// Try putting all parent dirs up to current working directory.
|
||||||
// First get absolute path to current working directory.
|
// First get absolute path to current working directory.
|
||||||
__attribute__((cleanup(free_malloced_memory))) void *cwd_dirname =
|
__attribute__((cleanup(free_malloced_memory))) void *cwd_dirname = NULL;
|
||||||
realpath(".", NULL);
|
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||||
|
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
||||||
|
cwd_dirname = realpath(".", NULL);
|
||||||
|
#endif
|
||||||
if (!cwd_dirname) {
|
if (!cwd_dirname) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,8 @@ SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
|
||||||
strcmp(dir_entry->d_name, "..") == 0) {
|
strcmp(dir_entry->d_name, "..") == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "dir entry in %s is %s\n", next, dir_entry->d_name);
|
// fprintf(stderr, "dir entry in %s is %s\n", next,
|
||||||
|
// dir_entry->d_name);
|
||||||
int combined_size = strlen(next) + strlen(dir_entry->d_name) + 2;
|
int combined_size = strlen(next) + strlen(dir_entry->d_name) + 2;
|
||||||
char *combined_path = malloc(combined_size);
|
char *combined_path = malloc(combined_size);
|
||||||
snprintf(combined_path, combined_size, "%s/%s", next,
|
snprintf(combined_path, combined_size, "%s/%s", next,
|
||||||
|
|
Loading…
Reference in a new issue