fix errno in os.nim
This commit is contained in:
parent
ea53cc7fcd
commit
43996c24a0
1 changed files with 5 additions and 2 deletions
|
|
@ -51,6 +51,8 @@ proc c_getenv(env: cstring): cstring {.
|
||||||
proc c_putenv(env: cstring): cint {.
|
proc c_putenv(env: cstring): cint {.
|
||||||
importc: "putenv", header: "<stdlib.h>".}
|
importc: "putenv", header: "<stdlib.h>".}
|
||||||
|
|
||||||
|
var errno {.importc, header: "<errno.h>".}: cint
|
||||||
|
|
||||||
proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
|
proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||||
## Retrieves the operating system's error flag, ``errno``.
|
## Retrieves the operating system's error flag, ``errno``.
|
||||||
## On Windows ``GetLastError`` is checked before ``errno``.
|
## On Windows ``GetLastError`` is checked before ``errno``.
|
||||||
|
|
@ -74,6 +76,7 @@ proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||||
nil, err, 0, addr(msgbuf), 0, nil) != 0'i32:
|
nil, err, 0, addr(msgbuf), 0, nil) != 0'i32:
|
||||||
result = $msgbuf
|
result = $msgbuf
|
||||||
if msgbuf != nil: localFree(msgbuf)
|
if msgbuf != nil: localFree(msgbuf)
|
||||||
|
else:
|
||||||
if errno != 0'i32:
|
if errno != 0'i32:
|
||||||
result = $os.c_strerror(errno)
|
result = $os.c_strerror(errno)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue