diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-31 11:21:30 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-31 13:51:49 +0100 |
commit | cdccc69c62579b0c13b35fad0728079652b8f3c9 (patch) | |
tree | 9fa54c710f73c5e08a9c8466e7a712eb63ee07ac /lib/fstree/get_path.c | |
parent | 2182129c8f359c4fa1390eaba7a65b595ccd4182 (diff) |
Move library source into src sub-directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/get_path.c')
-rw-r--r-- | lib/fstree/get_path.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/fstree/get_path.c b/lib/fstree/get_path.c deleted file mode 100644 index decf92e..0000000 --- a/lib/fstree/get_path.c +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * get_path.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" - -#include <string.h> -#include <stdlib.h> - -char *fstree_get_path(tree_node_t *node) -{ - tree_node_t *it; - char *str, *ptr; - size_t len = 0; - - if (node->parent == NULL) - return strdup("/"); - - for (it = node; it != NULL && it->parent != NULL; it = it->parent) { - len += strlen(it->name) + 1; - } - - str = malloc(len + 1); - if (str == NULL) - return NULL; - - ptr = str + len; - *ptr = '\0'; - - for (it = node; it != NULL && it->parent != NULL; it = it->parent) { - len = strlen(it->name); - ptr -= len; - - memcpy(ptr, it->name, len); - *(--ptr) = '/'; - } - - return str; -} |