Make nintendoswitch == posix
This commit is contained in:
parent
06ba653488
commit
cd42369dce
3 changed files with 14 additions and 14 deletions
|
|
@ -345,7 +345,7 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
|
||||||
osQnx, osAtari, osAix,
|
osQnx, osAtari, osAix,
|
||||||
osHaiku, osVxWorks, osSolaris, osNetbsd,
|
osHaiku, osVxWorks, osSolaris, osNetbsd,
|
||||||
osFreebsd, osOpenbsd, osDragonfly, osMacosx,
|
osFreebsd, osOpenbsd, osDragonfly, osMacosx,
|
||||||
osAndroid}
|
osAndroid, osNintendoSwitch}
|
||||||
of "linux":
|
of "linux":
|
||||||
result = conf.target.targetOS in {osLinux, osAndroid}
|
result = conf.target.targetOS in {osLinux, osAndroid}
|
||||||
of "bsd":
|
of "bsd":
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
import winlean
|
import winlean
|
||||||
elif defined(posix) or defined(nintendoswitch):
|
elif defined(posix):
|
||||||
import posix
|
import posix
|
||||||
|
|
||||||
proc toTime(ts: Timespec): times.Time {.inline.} =
|
proc toTime(ts: Timespec): times.Time {.inline.} =
|
||||||
|
|
@ -187,7 +187,7 @@ proc findExe*(exe: string, followSymlinks: bool = true;
|
||||||
|
|
||||||
proc getLastModificationTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
proc getLastModificationTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
||||||
## Returns the `file`'s last modification time.
|
## Returns the `file`'s last modification time.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var res: Stat
|
var res: Stat
|
||||||
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
||||||
result = res.st_mtim.toTime
|
result = res.st_mtim.toTime
|
||||||
|
|
@ -200,7 +200,7 @@ proc getLastModificationTime*(file: string): times.Time {.rtl, extern: "nos$1".}
|
||||||
|
|
||||||
proc getLastAccessTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
proc getLastAccessTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
||||||
## Returns the `file`'s last read or write access time.
|
## Returns the `file`'s last read or write access time.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var res: Stat
|
var res: Stat
|
||||||
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
||||||
result = res.st_atim.toTime
|
result = res.st_atim.toTime
|
||||||
|
|
@ -217,7 +217,7 @@ proc getCreationTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
||||||
## **Note:** Under POSIX OS's, the returned time may actually be the time at
|
## **Note:** Under POSIX OS's, the returned time may actually be the time at
|
||||||
## which the file's attribute's were last modified. See
|
## which the file's attribute's were last modified. See
|
||||||
## `here <https://github.com/nim-lang/Nim/issues/1058>`_ for details.
|
## `here <https://github.com/nim-lang/Nim/issues/1058>`_ for details.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var res: Stat
|
var res: Stat
|
||||||
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
if stat(file, res) < 0'i32: raiseOSError(osLastError())
|
||||||
result = res.st_ctim.toTime
|
result = res.st_ctim.toTime
|
||||||
|
|
@ -231,7 +231,7 @@ proc getCreationTime*(file: string): times.Time {.rtl, extern: "nos$1".} =
|
||||||
proc fileNewer*(a, b: string): bool {.rtl, extern: "nos$1".} =
|
proc fileNewer*(a, b: string): bool {.rtl, extern: "nos$1".} =
|
||||||
## Returns true if the file `a` is newer than file `b`, i.e. if `a`'s
|
## Returns true if the file `a` is newer than file `b`, i.e. if `a`'s
|
||||||
## modification time is later than `b`'s.
|
## modification time is later than `b`'s.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
# If we don't have access to nanosecond resolution, use '>='
|
# If we don't have access to nanosecond resolution, use '>='
|
||||||
when not StatHasNanoseconds:
|
when not StatHasNanoseconds:
|
||||||
result = getLastModificationTime(a) >= getLastModificationTime(b)
|
result = getLastModificationTime(a) >= getLastModificationTime(b)
|
||||||
|
|
@ -446,7 +446,7 @@ proc getFilePermissions*(filename: string): set[FilePermission] {.
|
||||||
## retrieves file permissions for `filename`. `OSError` is raised in case of
|
## retrieves file permissions for `filename`. `OSError` is raised in case of
|
||||||
## an error. On Windows, only the ``readonly`` flag is checked, every other
|
## an error. On Windows, only the ``readonly`` flag is checked, every other
|
||||||
## permission is available in any case.
|
## permission is available in any case.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var a: Stat
|
var a: Stat
|
||||||
if stat(filename, a) < 0'i32: raiseOSError(osLastError())
|
if stat(filename, a) < 0'i32: raiseOSError(osLastError())
|
||||||
result = {}
|
result = {}
|
||||||
|
|
@ -478,7 +478,7 @@ proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {.
|
||||||
## sets the file permissions for `filename`. `OSError` is raised in case of
|
## sets the file permissions for `filename`. `OSError` is raised in case of
|
||||||
## an error. On Windows, only the ``readonly`` flag is changed, depending on
|
## an error. On Windows, only the ``readonly`` flag is changed, depending on
|
||||||
## ``fpUserWrite``.
|
## ``fpUserWrite``.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var p = 0'i32
|
var p = 0'i32
|
||||||
if fpUserRead in permissions: p = p or S_IRUSR
|
if fpUserRead in permissions: p = p or S_IRUSR
|
||||||
if fpUserWrite in permissions: p = p or S_IWUSR
|
if fpUserWrite in permissions: p = p or S_IWUSR
|
||||||
|
|
@ -645,7 +645,7 @@ proc execShellCmd*(command: string): int {.rtl, extern: "nos$1",
|
||||||
## the process has finished. To execute a program without having a
|
## the process has finished. To execute a program without having a
|
||||||
## shell involved, use the `execProcess` proc of the `osproc`
|
## shell involved, use the `execProcess` proc of the `osproc`
|
||||||
## module.
|
## module.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
result = c_system(command) shr 8
|
result = c_system(command) shr 8
|
||||||
else:
|
else:
|
||||||
result = c_system(command)
|
result = c_system(command)
|
||||||
|
|
@ -739,7 +739,7 @@ type
|
||||||
pcLinkToDir ## path refers to a symbolic link to a directory
|
pcLinkToDir ## path refers to a symbolic link to a directory
|
||||||
|
|
||||||
|
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
proc getSymlinkFileKind(path: string): PathComponent =
|
proc getSymlinkFileKind(path: string): PathComponent =
|
||||||
# Helper function.
|
# Helper function.
|
||||||
var s: Stat
|
var s: Stat
|
||||||
|
|
@ -911,7 +911,7 @@ proc rawCreateDir(dir: string): bool =
|
||||||
result = false
|
result = false
|
||||||
else:
|
else:
|
||||||
raiseOSError(osLastError())
|
raiseOSError(osLastError())
|
||||||
elif defined(posix) or defined(nintendoswitch):
|
elif defined(posix):
|
||||||
let res = mkdir(dir, 0o777)
|
let res = mkdir(dir, 0o777)
|
||||||
if res == 0'i32:
|
if res == 0'i32:
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -1656,7 +1656,7 @@ proc isHidden*(path: string): bool =
|
||||||
proc setLastModificationTime*(file: string, t: times.Time) =
|
proc setLastModificationTime*(file: string, t: times.Time) =
|
||||||
## Sets the `file`'s last modification time. `OSError` is raised in case of
|
## Sets the `file`'s last modification time. `OSError` is raised in case of
|
||||||
## an error.
|
## an error.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
let unixt = posix.Time(t.toUnix)
|
let unixt = posix.Time(t.toUnix)
|
||||||
let micro = convert(Nanoseconds, Microseconds, t.nanosecond)
|
let micro = convert(Nanoseconds, Microseconds, t.nanosecond)
|
||||||
var timevals = [Timeval(tv_sec: unixt, tv_usec: micro),
|
var timevals = [Timeval(tv_sec: unixt, tv_usec: micro),
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ when defined(JS):
|
||||||
system.inc(a, b)
|
system.inc(a, b)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
import posix
|
import posix
|
||||||
|
|
||||||
type CTime = posix.Time
|
type CTime = posix.Time
|
||||||
|
|
@ -2031,7 +2031,7 @@ when not defined(JS):
|
||||||
## on the hardware/OS).
|
## on the hardware/OS).
|
||||||
##
|
##
|
||||||
## ``getTime`` should generally be prefered over this proc.
|
## ``getTime`` should generally be prefered over this proc.
|
||||||
when defined(posix) or defined(nintendoswitch):
|
when defined(posix):
|
||||||
var a: Timeval
|
var a: Timeval
|
||||||
gettimeofday(a)
|
gettimeofday(a)
|
||||||
result = toBiggestFloat(a.tv_sec.int64) + toFloat(a.tv_usec)*0.00_0001
|
result = toBiggestFloat(a.tv_sec.int64) + toFloat(a.tv_usec)*0.00_0001
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue