diff options
author | Dmitry Polienko <nigredo.tori@gmail.com> | 2016-10-22 17:53:51 +0700 |
---|---|---|
committer | Dmitry Polienko <nigredo.tori@gmail.com> | 2016-10-22 18:07:00 +0700 |
commit | 785e4022477248390565be20c52843b7b7c79222 (patch) | |
tree | 8e7cac579028f2e5a9fe140a3e8a9a0829ef8d67 | |
parent | 45b432b9010d267ef423338ffa70a1298eff7555 (diff) | |
download | Nim-785e4022477248390565be20c52843b7b7c79222.tar.gz |
Make `createDir` more robust
Should now properly work for root directories on Windows (after isAbsolute is fixed)
-rw-r--r-- | lib/pure/os.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 88b1bd280..83d98a3fe 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1064,8 +1064,10 @@ proc createDir*(dir: string) {.rtl, extern: "nos$1", tags: [WriteDirEffect].} = omitNext = false else: discard tryCreateDir(substr(dir, 0, i-1)) + # The loop does not create the dir itself if it doesn't end in separator - if dir[^1] notin {DirSep, AltSep}: + if dir.len > 0 and not omitNext and + dir[^1] notin {DirSep, AltSep}: discard tryCreateDir(dir) proc copyDir*(source, dest: string) {.rtl, extern: "nos$1", |