summaryrefslogtreecommitdiff
path: root/lib/fstree/node_from_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fstree/node_from_path.c')
-rw-r--r--lib/fstree/node_from_path.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/fstree/node_from_path.c b/lib/fstree/node_from_path.c
deleted file mode 100644
index 9140b2d..0000000
--- a/lib/fstree/node_from_path.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * node_from_path.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "fstree.h"
-
-#include <string.h>
-#include <errno.h>
-
-tree_node_t *fstree_node_from_path(fstree_t *fs, const char *path)
-{
- tree_node_t *n = fs->root;
- const char *end;
- size_t len;
-
- while (path != NULL && *path != '\0') {
- if (!S_ISDIR(n->mode)) {
- errno = ENOTDIR;
- return NULL;
- }
-
- end = strchrnul(path, '/');
- len = end - path;
-
- for (n = n->data.dir->children; n != NULL; n = n->next) {
- if (strncmp(path, n->name, len) != 0)
- continue;
- if (n->name[len] != '\0')
- continue;
- break;
- }
-
- if (n == NULL) {
- errno = ENOENT;
- return NULL;
- }
-
- path = *end ? (end + 1) : end;
- }
-
- return n;
-}