Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ compiler/c2nim/nimcache
compiler/pas2nim/nimcache
misc
doc/*.html
doc/*.pdf
doc/*.idx
/web/upload
koch
Expand Down
15 changes: 12 additions & 3 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1096,16 +1096,25 @@ proc rawCreateDir(dir: string) =
if res == 0'i32 and GetLastError() != 183'i32:
OSError()

proc createDir*(dir: string) {.rtl, extern: "nos$1", tags: [FWriteDir].} =
proc createDir*(dir: string) {.rtl, extern: "nos$1", tags: [FWriteDir,FReadDir].} =
## Creates the `directory`:idx: `dir`.
##
## The directory may contain several subdirectories that do not exist yet.
## The full path is created. If this fails, `EOS` is raised. It does **not**
## fail if the path already exists because for most usages this does not
## indicate an error.

var omitNext = false
when defined(doslike):
omitNext = isAbsolute(dir)
for i in 1.. dir.len-1:
if dir[i] in {dirsep, altsep}: rawCreateDir(substr(dir, 0, i-1))
rawCreateDir(dir)
if dir[i] in {dirsep, altsep}:
if omitNext:
omitNext = false
else:
var partDir = substr(dir, 0, i-1)
rawCreateDir(partDir)
rawCreateDir(dir)

proc copyDir*(source, dest: string) {.rtl, extern: "nos$1",
tags: [FWriteIO, FReadIO].} =
Expand Down