Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e236b37

Browse files
author
Vicent Martí
committed
Merge pull request libgit2#1633 from jamill/directory_create_fix
Allow creation of directories under the volume root in Win32
2 parents 947fad4 + daf98cb commit e236b37

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/fileops.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int git_futils_mkdir(
277277
mode_t mode,
278278
uint32_t flags)
279279
{
280-
int error = -1;
280+
int error = -1, tmp_errno;
281281
git_buf make_path = GIT_BUF_INIT;
282282
ssize_t root = 0;
283283
char lastch, *tail;
@@ -345,18 +345,26 @@ int git_futils_mkdir(
345345

346346
already_exists = 1;
347347
break;
348+
#ifdef GIT_WIN32
349+
case EACCES:
350+
#endif
348351
case ENOSYS:
349-
/* Solaris can generate this error if you try to mkdir
350-
* a path which is already a mount point. In that case,
351-
* the path does already exist; but it's not implied by
352+
/* The following errors can be generated if:
353+
* EACCES - Win32 can generate this error if you try to mkdir
354+
* a path which is the root of a volume.
355+
* ENOSYS - Solaris can generate a ENOSYS error if you try to mkdir
356+
* a path which is already a mount point.
357+
* In these cases, the path does already exist; but it's not implied by
352358
* the definition of the error, so let's recheck */
359+
tmp_errno = errno;
360+
353361
if (git_path_isdir(make_path.ptr)) {
354362
already_exists = 1;
355363
break;
356364
}
357365

358366
/* Fall through */
359-
errno = ENOSYS;
367+
errno = tmp_errno;
360368
default:
361369
giterr_set(GITERR_OS, "Failed to make directory '%s'",
362370
make_path.ptr);

0 commit comments

Comments
 (0)