diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/treepath_vfs.c | 10 | ||||
| -rw-r--r-- | common/treepathutils.c | 9 |
2 files changed, 13 insertions, 6 deletions
diff --git a/common/treepath_vfs.c b/common/treepath_vfs.c index a1c6e91..34a779a 100644 --- a/common/treepath_vfs.c +++ b/common/treepath_vfs.c @@ -40,7 +40,7 @@ struct VfsFilelistData* vfs_filelist_new(struct PathTree *files) log("vfs_filelist_new()\n"); data->files = files; - return data; + return data; } @@ -58,7 +58,7 @@ void vfs_filelist_free(struct VfsFilelistData *data) void vfs_filelist_set_files(struct VfsFilelistData *data, struct PathTree *files) { - if (data) data->files = files; + if (data) data->files = files; } @@ -75,13 +75,13 @@ u_int64_t internal_get_dir_size(struct VfsFilelistData *data, struct PathTree *t while ((n = filelist_tree_get_item_by_index(tree, idx))) { if (data->break_get_dir_size) break; if (n->data) { - log("internal_get_dir_size: found item '%s', size = %llu \n", n->node, n->data->iSize); + log("internal_get_dir_size: found item '%s', size = %zd \n", n->node, n->data->iSize); Size += (n->data->ItemType == vDirectory) ? internal_get_dir_size(data, n) : n->data->iSize; } idx++; } } - return Size; + return Size; } u_int64_t vfs_filelist_get_dir_size(struct VfsFilelistData *data, char *APath) @@ -112,7 +112,7 @@ long vfs_filelist_file_exists(struct VfsFilelistData *data, const char *FileName { if ((data) && (data->files)) { struct PathTree* node = filelist_tree_find_node_by_path(data->files, FileName); - return node != NULL; + return node != NULL; } else { printf ("(EE) VFSFileExists: Invalid pointers to data objects.\n"); return FALSE; diff --git a/common/treepathutils.c b/common/treepathutils.c index d3ace5a..2e43f94 100644 --- a/common/treepathutils.c +++ b/common/treepathutils.c @@ -119,6 +119,10 @@ void filelist_tree_print(struct PathTree *tree) struct PathTree* filelist_tree_find_node_by_path(struct PathTree *tree, const char *path) { + // remove leading './' + if (strstr(path, "./") == path) path += 2; + + // remove leading and trailing '/' if present char *p; if (IS_DIR_SEP(*path)) p = exclude_trailing_path_sep(path + 1); else p = exclude_trailing_path_sep(path); @@ -282,11 +286,14 @@ gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, const c return FALSE; } - if ((strcmp(path, "/") == 0) || (strcmp(path, ".") == 0) || (strcmp(path, "..") == 0)) { + if ((strcmp(path, "/") == 0) || (strcmp(path, ".") == 0) || (strcmp(path, "..") == 0) || (strcmp(path, "./") == 0)) { fprintf(stderr, "filelist_tree_add_item: path '%s' is not a valid path\n", path); return FALSE; } + // remove leading './' + if (strstr(path, "./") == path) path += 2; + // remove leading and trailing '/' if present char *p; if (IS_DIR_SEP(*path)) p = exclude_trailing_path_sep(path + 1); |
