diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 5a3b0a9b..f3571ac7 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -680,7 +680,8 @@ B list_c1(B d, B x) { return path_list(path_rel(nfn_objU(d), x)); } B createdir_c1(B d, B x) { - if (dir_create(path_rel(nfn_objU(d), x))) return m_i32(1); + B p = path_rel(nfn_objU(d), x); + if (dir_create(p)) return p; thrM("(file).CreateDir: Failed to create directory"); } diff --git a/src/utils/file.c b/src/utils/file.c index 5da570ac..5d4b5de5 100644 --- a/src/utils/file.c +++ b/src/utils/file.c @@ -309,7 +309,6 @@ bool dir_create(B path) { char* p = toCStr(path); bool r = mkdir(p, S_IRWXU) == 0; freeCStr(p); - dec(path); return r; } diff --git a/src/utils/file.h b/src/utils/file.h index b2127d46..27036c7c 100644 --- a/src/utils/file.h +++ b/src/utils/file.h @@ -14,7 +14,7 @@ B path_lines(B path); // consumes I8Arr* stream_bytes(FILE* f); B mmap_file(B path); // consumes -bool dir_create(B path); // consumes +bool dir_create(B path); // doesn't consume void path_wChars(B path, B x); // consumes path void path_wBytes(B path, B x); // consumes path