diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-15 22:14:21 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-11-15 22:14:21 +0100 |
| commit | f1ef4efb60e341a2a8ec72560071656b9d8b927d (patch) | |
| tree | 71ea4544495fca2a82f78e31beb81b83453e7cef /common/treepathutils.c | |
| parent | 1c50d6836601b8a6258dd6e299b3f299aa8d4a0f (diff) | |
| download | tuxcmd-modules-f1ef4efb60e341a2a8ec72560071656b9d8b927d.tar.xz | |
Encoding revision
Diffstat (limited to 'common/treepathutils.c')
| -rw-r--r-- | common/treepathutils.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/common/treepathutils.c b/common/treepathutils.c index d8a5f10..d3ace5a 100644 --- a/common/treepathutils.c +++ b/common/treepathutils.c @@ -42,6 +42,7 @@ struct PathTree* filelist_tree_new() tree->data = NULL; tree->index = 0; tree->node = strdup("/"); + tree->original_pathstr = NULL; // create placeholder data tree->data = (struct TVFSItem*)malloc(sizeof(struct TVFSItem)); @@ -83,6 +84,8 @@ void filelist_tree_free(struct PathTree *tree) } if (tree->node) free(tree->node); + if (tree->original_pathstr) + free(tree->original_pathstr); free(tree); } } @@ -182,7 +185,7 @@ unsigned long int filelist_find_index_by_path(struct PathTree *tree, const char else return 0; } -void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, struct TVFSItem *item, unsigned long index) +void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, const char *original_pathstr, struct TVFSItem *item, unsigned long index) { char *pos = strstr(path, "/"); char *first_part; @@ -208,6 +211,7 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru t->data = item; t->index = index; t->node = strdup(path); + if (original_pathstr) t->original_pathstr = strdup(original_pathstr); if (t->data) t->data->FName = strdup(path); if (t->data) t->data->FDisplayName = strdup(path); // create new list of subitems and add new item @@ -240,6 +244,7 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru node->items = g_ptr_array_new(); node->index = 0; node->node = strdup(first_part); + node->original_pathstr = NULL; // create placeholder data node->data = (struct TVFSItem*)malloc(sizeof(struct TVFSItem)); @@ -258,7 +263,7 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru } // and recurse one level deeper - filelist_tree_add_item_recurr(node, last_part, item, index); + filelist_tree_add_item_recurr(node, last_part, original_pathstr, item, index); } free(first_part); @@ -266,7 +271,7 @@ void filelist_tree_add_item_recurr(struct PathTree *tree, const char *path, stru } -gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, struct TVFSItem *item, unsigned long index) +gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, const char *original_pathstr, struct TVFSItem *item, unsigned long index) { if (! tree) { fprintf(stderr, "filelist_tree_add_item: tree == NULL !\n"); @@ -306,7 +311,7 @@ gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, struct if (found->data) found->data->FDisplayName = strdup(found->node); } else // create new item recursively - filelist_tree_add_item_recurr(tree, pp, item, index); + filelist_tree_add_item_recurr(tree, pp, original_pathstr, item, index); free(p); free(pp); |
