From f6b4abc7cacf512e4f8514203c98c090125c0338 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 16 Nov 2008 18:39:47 +0100 Subject: Prevent displaying './' items --- common/treepath_vfs.c | 10 +++++----- common/treepathutils.c | 9 ++++++++- libarchive/libarchive.c | 16 +--------------- 3 files changed, 14 insertions(+), 21 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); diff --git a/libarchive/libarchive.c b/libarchive/libarchive.c index 00f49a1..61d0071 100644 --- a/libarchive/libarchive.c +++ b/libarchive/libarchive.c @@ -260,18 +260,6 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) item->c_time = archive_entry_ctime(entry); item->a_time = archive_entry_atime(entry); -#if 0 - char *s; - if (! archive_entry_pathname_w(entry)) { - if (g_utf8_validate (archive_entry_pathname(entry), -1, NULL)) - s = g_strdup (archive_entry_pathname(entry)); - else - s = g_filename_display_name (archive_entry_pathname(entry)); - } - else - s = wide_to_utf8 (archive_entry_pathname_w(entry)); -#endif - char *s; if (g_utf8_validate (archive_entry_pathname(entry), -1, NULL)) s = g_strdup (archive_entry_pathname(entry)); @@ -281,8 +269,6 @@ TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName) else s = g_filename_display_name (archive_entry_pathname(entry)); } - - // g_print("file = '%s', wide = '%ls'\n", archive_entry_pathname(entry), archive_entry_pathname_w(entry)); // Add item to the global list and continue with next file @@ -567,7 +553,7 @@ my_archive_read_data_into_fd(struct TVFSGlobs *globs, struct archive *a, struct p += bytes_written; size -= bytes_written; - log(" (II) my_archive_read_data_into_fd: bytes_written = %u, total_written = %u\n", bytes_written, total_written); + log(" (II) my_archive_read_data_into_fd: bytes_written = %zd, total_written = %zd\n", bytes_written, total_written); if (globs->callback_progress) { if (! globs->callback_progress(total_written, file_size, globs->callback_data)) { cancel = TRUE; -- cgit v1.2.3