Commit 95e4c973 authored by Bernhard Link's avatar Bernhard Link

export dirs_create function

parent 0de6f5dc
......@@ -30,7 +30,7 @@
#include "names.h"
/* create directory dirname. */
static retvalue dirs_check(const char *dirname) {
retvalue dirs_create(const char *dirname) {
int ret, e;
ret = mkdir(dirname,0775);
......@@ -56,7 +56,7 @@ retvalue dirs_make_parent(const char *filename) {
for( p = filename+1, i = 1 ; *p != '\0' ; p++,i++) {
if( *p == '/' ) {
h = strndup(filename,i);
r = dirs_check(h);
r = dirs_create(h);
if( RET_WAS_ERROR(r) ) {
free(h);
return r;
......@@ -75,7 +75,7 @@ retvalue dirs_make_recursive(const char *directory) {
return RET_ERROR_INTERRUPTED;
}
r = dirs_make_parent(directory);
result = dirs_check(directory);
result = dirs_create(directory);
RET_UPDATE(result,r);
return result;
}
......@@ -130,7 +130,7 @@ retvalue dir_create_needed(const char *directory, int *createddepth) {
this = strndup(directory, len);
if( this == NULL )
return RET_ERROR_OOM;
r = dirs_check(this);
r = dirs_create(this);
free(this);
if( RET_WAS_ERROR(r) )
return r;
......
......@@ -10,6 +10,8 @@
#include "strlist.h"
#endif
/* create a directory, return RET_NOTHING if already existing */
retvalue dirs_create(const char *);
/* create recursively all parent directories before the last '/' */
retvalue dirs_make_parent(const char *filename);
/* create dirname and any '/'-separated part of it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment