Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Fixed mkpath.

  • Loading branch information...
commit 3fd2bbcd76e3e8222559af2559a32cbc3be66ade 1 parent 331e520
@bobbens bobbens authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/nfile.c
View
16 src/nfile.c
@@ -259,21 +259,25 @@ static int mkpath( const char *path, mode_t mode )
size_t len;
int ret;
+ if (path == NULL)
+ return 0;
+
strncpy( opath, path, sizeof(opath) );
len = strlen(opath);
if (opath[len - 1] == '/')
opath[len - 1] = '\0';
- for (p = opath; *p; p++)
- if (*p == '/') {
- *p = '\0';
- if (access(opath, F_OK)) {
+ for (p=&opath[1]; p[0]!='\0'; p++) {
+ if (p[0] == '/') {
+ p[0] = '\0';
+ if (!nfile_dirExists(opath)) {
ret = mkdir( opath, mode );
if (ret)
return ret;
}
- *p = '/';
+ p[0] = '/';
}
- if (access(opath, F_OK)) { /* if path is not terminated with / */
+ }
+ if (!nfile_dirExists(opath)) { /* if path is not terminated with / */
ret = mkdir( opath, mode );
if (ret)
return ret;
Please sign in to comment.
Something went wrong with that request. Please try again.