aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/util.c b/util.c
index d580839..e9c899b 100644
--- a/util.c
+++ b/util.c
@@ -193,10 +193,11 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
int r_mkdir(char *path)
{
+ int rc = 0;
char c, *s = path;
struct stat st;
- while (*s != '\0') {
+ while (*s != '\0' && rc == 0) {
if (*s == '/') {
s++;
continue;
@@ -204,12 +205,15 @@ int r_mkdir(char *path)
for (; *s != '\0' && *s != '/'; s++);
c = *s;
*s = '\0';
- if (mkdir(path, 0755) == -1)
- if (errno != EEXIST || stat(path, &st) == -1 || !S_ISDIR(st.st_mode))
- return -1;
+ if (mkdir(path, 0755) == -1) {
+ if (errno != EEXIST || stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
+ error(0, errno, "%s", path);
+ rc = -1;
+ }
+ }
*s = c;
}
- return 0;
+ return rc;
}
void construct_argv(char **argv, unsigned int len, ...)