diff options
-rwxr-xr-x | lib/pure/os.nim | 17 | ||||
-rwxr-xr-x | lib/pure/osproc.nim | 8 |
2 files changed, 11 insertions, 14 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 81a038de7..7847fa332 100755 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2010 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -148,8 +148,9 @@ const ## for example, the '.' in ``os.nim``. proc OSErrorMsg*(): string {.rtl, extern: "nos$1".} = - ## Retrieves the operating system's error flag, ``errno`` on Posix and - ## ``GetLastError`` on Windows. + ## Retrieves the operating system's error flag, ``errno``. + ## On Windows ``GetLastError`` is checked before ``errno``. + ## Returns "" if no error occured. result = "" when defined(Windows): var err = GetLastError() @@ -161,9 +162,8 @@ proc OSErrorMsg*(): string {.rtl, extern: "nos$1".} = if msgbuf != nil: LocalFree(msgbuf) result = m - else: - if errno != 0'i32: - result = $os.strerror(errno) + if errno != 0'i32: + result = $os.strerror(errno) proc OSError*(msg: string = "") {.noinline, rtl, extern: "nos$1".} = ## raises an EOS exception with the given message ``msg``. @@ -173,10 +173,7 @@ proc OSError*(msg: string = "") {.noinline, rtl, extern: "nos$1".} = ## If no error flag is set, the message ``unknown OS error`` is used. if len(msg) == 0: var m = OSErrorMsg() - if m != "": - raise newException(EOS, m) - else: - raise newException(EOS, "unknown OS error") + raise newException(EOS, if m.len > 0: m else: "unknown OS error") else: raise newException(EOS, msg) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index a539e5f39..a4a854c49 100755 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -200,10 +200,10 @@ proc execProcesses*(cmds: openArray[string], result = max(waitForExit(p), result) proc select*(readfds: var seq[PProcess], timeout = 500): int - ## select with a sensible Nimrod interface. `timeout` is in miliseconds. - ## Specify -1 for no timeout. Returns the number of file handles that are - ## ready. The processes that are ready to be read from are removed from - ## `readfds`. + ## `select` with a sensible Nimrod interface. `timeout` is in miliseconds. + ## Specify -1 for no timeout. Returns the number of processes that are + ## ready to read from. The processes that are ready to be read from are + ## removed from `readfds`. when not defined(useNimRtl): proc execProcess(command: string, |