Posix from detect (#5697)
* refactor posix.nim
* types move to separate files for platform-specifc and generic
("other')
* consts move to separate files that get autogenerated by detect.nim
* proc's stay where they are for now, though in a second stage might
move as well
* fix missing when
This commit is contained in:
parent
e512358bc9
commit
ce86b4ad78
12 changed files with 3438 additions and 3133 deletions
|
|
@ -312,7 +312,7 @@ proc setFilePos*(f: AsyncFile, pos: int64) =
|
|||
## operations. The file's first byte has the index zero.
|
||||
f.offset = pos
|
||||
when not defined(windows) and not defined(nimdoc):
|
||||
let ret = lseek(f.fd.cint, pos, SEEK_SET)
|
||||
let ret = lseek(f.fd.cint, pos.Off, SEEK_SET)
|
||||
if ret == -1:
|
||||
raiseOSError(osLastError())
|
||||
|
||||
|
|
@ -481,7 +481,8 @@ proc setFileSize*(f: AsyncFile, length: int64) =
|
|||
(setEndOfFile(f.fd.Handle) == 0):
|
||||
raiseOSError(osLastError())
|
||||
else:
|
||||
if ftruncate(f.fd.cint, length) == -1:
|
||||
# will truncate if Off is a 32-bit type!
|
||||
if ftruncate(f.fd.cint, length.Off) == -1:
|
||||
raiseOSError(osLastError())
|
||||
|
||||
proc close*(f: AsyncFile) =
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ proc `==`*(a, b: Port): bool {.borrow.}
|
|||
proc `$`*(p: Port): string {.borrow.}
|
||||
## returns the port number as a string
|
||||
|
||||
proc toInt*(domain: Domain): cint
|
||||
proc toInt*(domain: Domain): cshort
|
||||
## Converts the Domain enum to a platform-dependent ``cint``.
|
||||
|
||||
proc toInt*(typ: SockType): cint
|
||||
|
|
@ -123,11 +123,11 @@ proc toInt*(p: Protocol): cint
|
|||
## Converts the Protocol enum to a platform-dependent ``cint``.
|
||||
|
||||
when not useWinVersion:
|
||||
proc toInt(domain: Domain): cint =
|
||||
proc toInt(domain: Domain): cshort =
|
||||
case domain
|
||||
of AF_UNIX: result = posix.AF_UNIX
|
||||
of AF_INET: result = posix.AF_INET
|
||||
of AF_INET6: result = posix.AF_INET6
|
||||
of AF_UNIX: result = posix.AF_UNIX.cshort
|
||||
of AF_INET: result = posix.AF_INET.cshort
|
||||
of AF_INET6: result = posix.AF_INET6.cshort
|
||||
else: discard
|
||||
|
||||
proc toInt(typ: SockType): cint =
|
||||
|
|
@ -149,7 +149,7 @@ when not useWinVersion:
|
|||
else: discard
|
||||
|
||||
else:
|
||||
proc toInt(domain: Domain): cint =
|
||||
proc toInt(domain: Domain): cshort =
|
||||
result = toU16(ord(domain))
|
||||
|
||||
proc toInt(typ: SockType): cint =
|
||||
|
|
|
|||
|
|
@ -1716,7 +1716,7 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
|
|||
formalInfo.permissions.incl(formalMode)
|
||||
formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
|
||||
formalInfo.size = rawInfo.st_size
|
||||
formalInfo.linkCount = rawInfo.st_Nlink
|
||||
formalInfo.linkCount = rawInfo.st_Nlink.BiggestInt
|
||||
formalInfo.lastAccessTime = rawInfo.st_atime
|
||||
formalInfo.lastWriteTime = rawInfo.st_mtime
|
||||
formalInfo.creationTime = rawInfo.st_ctime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue