io: correct signature for some win32 apis (#14551)
See https://github.com/nim-lang/Nim/pull/14550#issuecomment-637937649
This commit is contained in:
parent
4301a3da9d
commit
55f0df164b
1 changed files with 5 additions and 5 deletions
|
|
@ -279,10 +279,10 @@ elif defined(posix) and not defined(nimscript):
|
||||||
importc: "fcntl", header: "<fcntl.h>", varargs.}
|
importc: "fcntl", header: "<fcntl.h>", varargs.}
|
||||||
elif defined(windows):
|
elif defined(windows):
|
||||||
const HANDLE_FLAG_INHERIT = culong 0x1
|
const HANDLE_FLAG_INHERIT = culong 0x1
|
||||||
proc getOsfhandle(fd: cint): FileHandle {.
|
proc getOsfhandle(fd: cint): int {.
|
||||||
importc: "_get_osfhandle", header: "<io.h>".}
|
importc: "_get_osfhandle", header: "<io.h>".}
|
||||||
|
|
||||||
proc setHandleInformation(handle: FileHandle, mask, flags: culong): cint {.
|
proc setHandleInformation(handle: int, mask, flags: culong): cint {.
|
||||||
importc: "SetHandleInformation", header: "<handleapi.h>".}
|
importc: "SetHandleInformation", header: "<handleapi.h>".}
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -318,7 +318,7 @@ proc getOsFileHandle*(f: File): FileHandle =
|
||||||
## returns the OS file handle of the file ``f``. This is only useful for
|
## returns the OS file handle of the file ``f``. This is only useful for
|
||||||
## platform specific programming.
|
## platform specific programming.
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = getOsfhandle(getFileHandle(f))
|
result = FileHandle getOsfhandle(cint getFileHandle(f))
|
||||||
else:
|
else:
|
||||||
result = c_fileno(f)
|
result = c_fileno(f)
|
||||||
|
|
||||||
|
|
@ -339,7 +339,7 @@ when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(w
|
||||||
flags = if inheritable: flags and not FD_CLOEXEC else: flags or FD_CLOEXEC
|
flags = if inheritable: flags and not FD_CLOEXEC else: flags or FD_CLOEXEC
|
||||||
result = c_fcntl(f, F_SETFD, flags) != -1
|
result = c_fcntl(f, F_SETFD, flags) != -1
|
||||||
else:
|
else:
|
||||||
result = setHandleInformation(f, HANDLE_FLAG_INHERIT, culong inheritable) != 0
|
result = setHandleInformation(f.int, HANDLE_FLAG_INHERIT, culong inheritable) != 0
|
||||||
|
|
||||||
proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
|
proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
|
||||||
benign.} =
|
benign.} =
|
||||||
|
|
@ -647,7 +647,7 @@ proc open*(f: var File, filehandle: FileHandle,
|
||||||
##
|
##
|
||||||
## The passed file handle will no longer be inheritable.
|
## The passed file handle will no longer be inheritable.
|
||||||
when not defined(nimInheritHandles) and declared(setInheritable):
|
when not defined(nimInheritHandles) and declared(setInheritable):
|
||||||
let oshandle = when defined(windows): getOsfhandle(filehandle) else: filehandle
|
let oshandle = when defined(windows): FileHandle getOsfhandle(filehandle) else: filehandle
|
||||||
if not setInheritable(oshandle, false):
|
if not setInheritable(oshandle, false):
|
||||||
return false
|
return false
|
||||||
f = c_fdopen(filehandle, FormatOpen[mode])
|
f = c_fdopen(filehandle, FormatOpen[mode])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue