diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-16 18:39:47 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-16 18:39:47 +0100 |
| commit | f6b4abc7cacf512e4f8514203c98c090125c0338 (patch) | |
| tree | 170e5434a34d7b9de08f3a9863b4f2a28003ffd9 /common/treepathutils.c | |
| parent | f1ef4efb60e341a2a8ec72560071656b9d8b927d (diff) | |
| download | tuxcmd-modules-f6b4abc7cacf512e4f8514203c98c090125c0338.tar.xz | |
Prevent displaying './' items
Diffstat (limited to 'common/treepathutils.c')
| -rw-r--r-- | common/treepathutils.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |
