summaryrefslogtreecommitdiff
path: root/utils/filepath.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/filepath.c')
-rw-r--r--utils/filepath.c57
1 files changed, 0 insertions, 57 deletions
diff --git a/utils/filepath.c b/utils/filepath.c
index c28a821d7..c07cc4874 100644
--- a/utils/filepath.c
+++ b/utils/filepath.c
@@ -325,60 +325,3 @@ void filepath_free_strvec(char **pathv)
free(pathv);
}
-/* exported interface documented in filepath.h */
-nserror filepath_mkdir_all(const char *fname)
-{
- char *dname;
- char *sep;
- struct stat sb;
-
- dname = strdup(fname);
-
- sep = strrchr(dname, '/');
- if (sep == NULL) {
- /* no directory separator path is just filename so its ok */
- free(dname);
- return NSERROR_OK;
- }
-
- *sep = 0; /* null terminate directory path */
-
- if (stat(dname, &sb) == 0) {
- free(dname);
- if (S_ISDIR(sb.st_mode)) {
- /* path to file exists and is a directory */
- return NSERROR_OK;
- }
- return NSERROR_NOT_DIRECTORY;
- }
- *sep = '/'; /* restore separator */
-
- sep = dname;
- while (*sep == '/') {
- sep++;
- }
- while ((sep = strchr(sep, '/')) != NULL) {
- *sep = 0;
- if (stat(dname, &sb) != 0) {
- if (nsmkdir(dname, S_IRWXU) != 0) {
- /* could not create path element */
- free(dname);
- return NSERROR_NOT_FOUND;
- }
- } else {
- if (! S_ISDIR(sb.st_mode)) {
- /* path element not a directory */
- free(dname);
- return NSERROR_NOT_DIRECTORY;
- }
- }
- *sep = '/'; /* restore separator */
- /* skip directory separators */
- while (*sep == '/') {
- sep++;
- }
- }
-
- free(dname);
- return NSERROR_OK;
-}