The idea of this module is to allow callers to pretend their system has the Linux statx call & Statx type even if it does not. Callers simply program to the "superset" using Statx and statx and i just works. We simulate/translate ordinary Stat results when necessary.
Types
Statx {.importc: "struct statx", header: "<sys/stat.h>", final, pure.} = object stx_mask*: uint32 ## Mask of bits indicating filled fields stx_blksize*: uint32 ## Block size for filesystem I/O stx_attributes*: uint64 ## Extra file attribute indicators stx_nlink*: uint32 ## Number of hard links stx_uid*: uint32 ## User ID of owner stx_gid*: uint32 ## Group ID of owner stx_mode*: uint16 ## File type and mode stx_ino*: uint64 ## Inode number stx_size*: uint64 ## Total size in bytes stx_blocks*: uint64 ## Number of 512B blocks allocated stx_attributes_mask*: uint64 ## Mask showing supported by stx_attributes stx_atime*: StatxTs ## Last access stx_btime*: StatxTs ## Birth/Creation stx_ctime*: StatxTs ## Last status change stx_mtime*: StatxTs ## Last modification stx_rdev_major*: uint32 ## Major ID if file is a device stx_rdev_minor*: uint32 ## Minor ID if file is a device stx_dev_major*: uint32 ## Major ID of dev of FS where file resides stx_dev_minor*: uint32 ## Minor ID of dev of FS where file resides
- struct statx
StatxTs {.importc: "struct statx_timestamp", header: "<sys/stat.h>", final, pure.} = object tv_sec*: int64 tv_nsec*: int32
Lets
AT_STATX_DONT_SYNC {.inject.} = locAT_STATX_DONT_SYNC
AT_STATX_FORCE_SYNC {.inject.} = locAT_STATX_FORCE_SYNC
AT_STATX_SYNC_AS_STAT {.inject.} = locAT_STATX_SYNC_AS_STAT
AT_STATX_SYNC_TYPE {.inject.} = locAT_STATX_SYNC_TYPE
STATX_ALL {.inject.} = locSTATX_ALL
STATX_ATIME {.inject.} = locSTATX_ATIME
STATX_ATTR_APPEND {.inject.} = locSTATX_ATTR_APPEND
STATX_ATTR_AUTOMOUNT {.inject.} = locSTATX_ATTR_AUTOMOUNT
STATX_ATTR_COMPRESSED {.inject.} = locSTATX_ATTR_COMPRESSED
STATX_ATTR_ENCRYPTED {.inject.} = locSTATX_ATTR_ENCRYPTED
STATX_ATTR_IMMUTABLE {.inject.} = locSTATX_ATTR_IMMUTABLE
STATX_ATTR_NODUMP {.inject.} = locSTATX_ATTR_NODUMP
STATX_BASIC_STATS {.inject.} = locSTATX_BASIC_STATS
STATX_BLOCKS {.inject.} = locSTATX_BLOCKS
STATX_BTIME {.inject.} = locSTATX_BTIME
STATX_CTIME {.inject.} = locSTATX_CTIME
STATX_GID {.inject.} = locSTATX_GID
STATX_INO {.inject.} = locSTATX_INO
STATX_MODE {.inject.} = locSTATX_MODE
STATX_MTIME {.inject.} = locSTATX_MTIME
STATX_NLINK {.inject.} = locSTATX_NLINK
STATX_SIZE {.inject.} = locSTATX_SIZE
STATX_TYPE {.inject.} = locSTATX_TYPE
STATX_UID {.inject.} = locSTATX_UID
Procs
proc fileTime(path: string; kind: char; missing = int64(0); dir = 1): int64 {. ...raises: [], tags: [], forbids: [].}
- Return file time stamp ([bamcv]) in nanoseconds since the Unix epoch.
proc fstatx(fd: cint; stx: var Statx; flags = (0x00001000 or statxFlags); mask = statxMask): cint {.inline, ...raises: [], tags: [], forbids: [].}
- A Linux statx wrapper with a call signature more like regular fstat.
proc getBirthTimeNsec(path: string): int64 {....raises: [], tags: [], forbids: [].}
proc getBirthTimeNsec(stx`gensym52: Statx): int64 {.inline, ...raises: [], tags: [], forbids: [].}
proc getCreationTimeNsec(stx`gensym51: Statx): int64 {.inline, ...raises: [], tags: [], forbids: [].}
proc getLastAccTimeNsec(stx`gensym49: Statx): int64 {.inline, ...raises: [], tags: [], forbids: [].}
proc getLastModTimeNsec(stx`gensym50: Statx): int64 {.inline, ...raises: [], tags: [], forbids: [].}
proc lstatx(path: cstring; stx: var Statx; flags = (statxFlags or AT_SYMLINK_NOFOLLOW); mask = statxMask): cint {. inline, ...raises: [], tags: [], forbids: [].}
- A Linux statx wrapper with a call signature more like regular lstat.
proc st_blksize(st: Statx): Blksize {.inline, ...raises: [], tags: [], forbids: [].}
proc st_major(dno: Dev): uint32 {.inline, ...raises: [], tags: [], forbids: [].}
proc st_minor(dno: Dev): uint32 {.inline, ...raises: [], tags: [], forbids: [].}
proc statx(dirfd: cint; path: cstring; flags: cint; mask: cint; stx: ptr Statx): cint {. importc: "statx", header: "<sys/stat.h>", ...raises: [], tags: [], forbids: [].}
proc statx(dirfd: cint; path: cstring; flags: cint; stx: var Statx; mask = statxMask): cint {.inline, ...raises: [], tags: [], forbids: [].}
- A statx that looks more like fstatat w/a final parameter ignored when simulated.
proc toTimespec(ts: StatxTs): Timespec {.inline, ...raises: [], tags: [], forbids: [].}