diff options
author | lum <lum@cvs.openbsd.org> | 2013-05-17 04:59:30 +0000 |
---|---|---|
committer | lum <lum@cvs.openbsd.org> | 2013-05-17 04:59:30 +0000 |
commit | 074ce6d94a87a96c82a5ab95a8649fcd1de8bcc8 (patch) | |
tree | d79777d8067efc5a06855ee02e84322e8dcd5c8d | |
parent | 8f5d94d6e07b03186eb05fbda73848d4d2eced31 (diff) |
If directory exists when trying to create a new one, warn user.
ok jasper@
-rw-r--r-- | usr.bin/mg/dir.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index 56867a57615..fddcf021be8 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.20 2012/11/27 19:46:46 jasper Exp $ */ +/* $OpenBSD: dir.c,v 1.21 2013/05/17 04:59:29 lum Exp $ */ /* This file is in the public domain. */ @@ -116,7 +116,11 @@ makedir(int f, int n) *slash = '\0'; ishere = !stat(path, &sb); - if (!finished && ishere && S_ISDIR(sb.st_mode)) { + if (finished && ishere) { + ewprintf("Cannot create directory %s: file exists", + path); + return(FALSE); + } else if (!finished && ishere && S_ISDIR(sb.st_mode)) { *slash = '/'; continue; } |