parent
e0f3e8432a
commit
5a8fddf29b
6 changed files with 37 additions and 26 deletions
|
|
@ -95,9 +95,9 @@ const StatHasNanoseconds* = defined(linux) or defined(freebsd) or
|
||||||
|
|
||||||
# Platform specific stuff
|
# Platform specific stuff
|
||||||
|
|
||||||
when defined(linux) and defined(amd64):
|
when (defined(linux) and not defined(android)) and defined(amd64):
|
||||||
include posix_linux_amd64
|
include posix_linux_amd64
|
||||||
elif (defined(macosx) or defined(bsd)) and defined(cpu64):
|
elif (defined(macos) or defined(macosx) or defined(bsd)) and defined(cpu64):
|
||||||
include posix_macos_amd64
|
include posix_macos_amd64
|
||||||
elif defined(nintendoswitch):
|
elif defined(nintendoswitch):
|
||||||
include posix_nintendoswitch
|
include posix_nintendoswitch
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ type
|
||||||
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
|
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
|
||||||
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
|
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
|
||||||
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
|
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
|
||||||
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = cint # cuint really!
|
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
|
||||||
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
|
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
|
||||||
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
|
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
|
||||||
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
|
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,12 @@ type
|
||||||
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
|
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
|
||||||
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
|
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
|
||||||
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
|
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
|
||||||
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = int16
|
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
|
||||||
|
when defined(openbsd) or defined(netbsd):
|
||||||
|
uint32
|
||||||
|
else:
|
||||||
|
uint16
|
||||||
|
)
|
||||||
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int16
|
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int16
|
||||||
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
|
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
|
||||||
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
|
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ type
|
||||||
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
|
Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
|
||||||
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
|
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
|
||||||
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
|
Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
|
||||||
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = cint # cuint really!
|
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint16
|
||||||
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
|
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
|
||||||
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
|
Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
|
||||||
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
|
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,13 @@ type
|
||||||
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
|
Id* {.importc: "id_t", header: "<sys/types.h>".} = int
|
||||||
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
|
Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
|
||||||
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
|
Key* {.importc: "key_t", header: "<sys/types.h>".} = int
|
||||||
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = cint
|
Mode* {.importc: "mode_t", header: "<sys/types.h>".} = (
|
||||||
|
when defined(android) or defined(macos) or defined(macosx) or
|
||||||
|
(defined(bsd) and not defined(openbsd) and not defined(netbsd)):
|
||||||
|
uint16
|
||||||
|
else:
|
||||||
|
uint32
|
||||||
|
)
|
||||||
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int
|
Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int
|
||||||
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
|
Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
|
||||||
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
|
Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
|
||||||
|
|
|
||||||
|
|
@ -1435,17 +1435,17 @@ proc getFilePermissions*(filename: string): set[FilePermission] {.
|
||||||
var a: Stat
|
var a: Stat
|
||||||
if stat(filename, a) < 0'i32: raiseOSError(osLastError())
|
if stat(filename, a) < 0'i32: raiseOSError(osLastError())
|
||||||
result = {}
|
result = {}
|
||||||
if (a.st_mode and S_IRUSR) != 0'i32: result.incl(fpUserRead)
|
if (a.st_mode and S_IRUSR.Mode) != 0.Mode: result.incl(fpUserRead)
|
||||||
if (a.st_mode and S_IWUSR) != 0'i32: result.incl(fpUserWrite)
|
if (a.st_mode and S_IWUSR.Mode) != 0.Mode: result.incl(fpUserWrite)
|
||||||
if (a.st_mode and S_IXUSR) != 0'i32: result.incl(fpUserExec)
|
if (a.st_mode and S_IXUSR.Mode) != 0.Mode: result.incl(fpUserExec)
|
||||||
|
|
||||||
if (a.st_mode and S_IRGRP) != 0'i32: result.incl(fpGroupRead)
|
if (a.st_mode and S_IRGRP.Mode) != 0.Mode: result.incl(fpGroupRead)
|
||||||
if (a.st_mode and S_IWGRP) != 0'i32: result.incl(fpGroupWrite)
|
if (a.st_mode and S_IWGRP.Mode) != 0.Mode: result.incl(fpGroupWrite)
|
||||||
if (a.st_mode and S_IXGRP) != 0'i32: result.incl(fpGroupExec)
|
if (a.st_mode and S_IXGRP.Mode) != 0.Mode: result.incl(fpGroupExec)
|
||||||
|
|
||||||
if (a.st_mode and S_IROTH) != 0'i32: result.incl(fpOthersRead)
|
if (a.st_mode and S_IROTH.Mode) != 0.Mode: result.incl(fpOthersRead)
|
||||||
if (a.st_mode and S_IWOTH) != 0'i32: result.incl(fpOthersWrite)
|
if (a.st_mode and S_IWOTH.Mode) != 0.Mode: result.incl(fpOthersWrite)
|
||||||
if (a.st_mode and S_IXOTH) != 0'i32: result.incl(fpOthersExec)
|
if (a.st_mode and S_IXOTH.Mode) != 0.Mode: result.incl(fpOthersExec)
|
||||||
else:
|
else:
|
||||||
when useWinUnicode:
|
when useWinUnicode:
|
||||||
wrapUnary(res, getFileAttributesW, filename)
|
wrapUnary(res, getFileAttributesW, filename)
|
||||||
|
|
@ -1470,18 +1470,18 @@ proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {.
|
||||||
## * `getFilePermissions <#getFilePermissions,string>`_
|
## * `getFilePermissions <#getFilePermissions,string>`_
|
||||||
## * `FilePermission enum <#FilePermission>`_
|
## * `FilePermission enum <#FilePermission>`_
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
var p = 0'i32
|
var p = 0.Mode
|
||||||
if fpUserRead in permissions: p = p or S_IRUSR
|
if fpUserRead in permissions: p = p or S_IRUSR.Mode
|
||||||
if fpUserWrite in permissions: p = p or S_IWUSR
|
if fpUserWrite in permissions: p = p or S_IWUSR.Mode
|
||||||
if fpUserExec in permissions: p = p or S_IXUSR
|
if fpUserExec in permissions: p = p or S_IXUSR.Mode
|
||||||
|
|
||||||
if fpGroupRead in permissions: p = p or S_IRGRP
|
if fpGroupRead in permissions: p = p or S_IRGRP.Mode
|
||||||
if fpGroupWrite in permissions: p = p or S_IWGRP
|
if fpGroupWrite in permissions: p = p or S_IWGRP.Mode
|
||||||
if fpGroupExec in permissions: p = p or S_IXGRP
|
if fpGroupExec in permissions: p = p or S_IXGRP.Mode
|
||||||
|
|
||||||
if fpOthersRead in permissions: p = p or S_IROTH
|
if fpOthersRead in permissions: p = p or S_IROTH.Mode
|
||||||
if fpOthersWrite in permissions: p = p or S_IWOTH
|
if fpOthersWrite in permissions: p = p or S_IWOTH.Mode
|
||||||
if fpOthersExec in permissions: p = p or S_IXOTH
|
if fpOthersExec in permissions: p = p or S_IXOTH.Mode
|
||||||
|
|
||||||
if chmod(filename, cast[Mode](p)) != 0: raiseOSError(osLastError())
|
if chmod(filename, cast[Mode](p)) != 0: raiseOSError(osLastError())
|
||||||
else:
|
else:
|
||||||
|
|
@ -2854,7 +2854,7 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
|
||||||
|
|
||||||
else:
|
else:
|
||||||
template checkAndIncludeMode(rawMode, formalMode: untyped) =
|
template checkAndIncludeMode(rawMode, formalMode: untyped) =
|
||||||
if (rawInfo.st_mode and rawMode) != 0'i32:
|
if (rawInfo.st_mode and rawMode.Mode) != 0.Mode:
|
||||||
formalInfo.permissions.incl(formalMode)
|
formalInfo.permissions.incl(formalMode)
|
||||||
formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
|
formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino)
|
||||||
formalInfo.size = rawInfo.st_size
|
formalInfo.size = rawInfo.st_size
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue