diff options
Diffstat (limited to 'src/nxt_fs.c')
-rw-r--r-- | src/nxt_fs.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nxt_fs.c b/src/nxt_fs.c index 71498f99..35850798 100644 --- a/src/nxt_fs.c +++ b/src/nxt_fs.c @@ -273,6 +273,31 @@ nxt_fs_mkdir_all(const u_char *dir, mode_t mode) } +nxt_int_t +nxt_fs_mkdir_parent(const u_char *path, mode_t mode) +{ + char *ptr, *dir; + nxt_int_t ret; + + dir = nxt_strdup(path); + if (nxt_slow_path(dir == NULL)) { + return NXT_ERROR; + } + + ret = NXT_OK; + + ptr = strrchr(dir, '/'); + if (nxt_fast_path(ptr != NULL)) { + *ptr = '\0'; + ret = nxt_fs_mkdir((const u_char *) dir, mode); + } + + nxt_free(dir); + + return ret; +} + + static nxt_int_t nxt_fs_mkdir(const u_char *dir, mode_t mode) { |