diff options
| author | Wayne Davison <wayned@samba.org> | 2006-02-24 09:34:44 +0000 |
|---|---|---|
| committer | Wayne Davison <wayned@samba.org> | 2006-02-24 09:34:44 +0000 |
| commit | 85c417579f5cb56f29b9ec7d6b5509c99358a285 (patch) | |
| tree | b538c1cea54583f69b017ef10ae5d4631c18c4b7 /util.c | |
| parent | baed67efc471537da02720a4ef883a014b24cb9b (diff) | |
| download | android_external_rsync-85c417579f5cb56f29b9ec7d6b5509c99358a285.tar.gz android_external_rsync-85c417579f5cb56f29b9ec7d6b5509c99358a285.tar.bz2 android_external_rsync-85c417579f5cb56f29b9ec7d6b5509c99358a285.zip | |
Made create_directory_path() return -1 if it couldn't create some
portion of the filename's path.
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -184,28 +184,29 @@ int mkdir_defmode(char *fname) return ret; } -/** - Create any necessary directories in fname. Unfortunately we don't know - what perms to give the directory when this is called so we need to rely - on the umask -**/ +/* Create any necessary directories in fname. Any missing directories are + * created with default permissions. */ int create_directory_path(char *fname) { char *p; + int ret = 0; while (*fname == '/') fname++; while (strncmp(fname, "./", 2) == 0) fname += 2; + umask(orig_umask); p = fname; while ((p = strchr(p,'/')) != NULL) { - *p = 0; - mkdir_defmode(fname); - *p = '/'; - p++; + *p = '\0'; + if (do_mkdir(fname, ACCESSPERMS) < 0 && errno != EEXIST) + ret = -1; + *p++ = '/'; } - return 0; + umask(0); + + return ret; } /** |
