src/pylib/Lib/os_impl/posix_like/stat

Source   Edit  

Types

stat_result = tuple[st_mode: Mode, st_ino: Ino, st_dev: Dev, st_nlink: Nlink,
                    st_uid: Uid, st_gid: Gid, st_size: Off,
                    st_atime, st_mtime, st_ctime: Time64, st_blocks: Blkcnt,
                    st_blksize: Blksize, st_rdev: Dev]
Python's os.stat_result (a NamedTuple) Source   Edit  

Procs

proc stat(path: int): stat_result {....raises: [OSError], tags: [], forbids: [].}
Source   Edit  
proc stat[T](path: PathLike[T]): stat_result
Warning: Under Windows, it's just a wrapper over _wstat, so this differs from Python's os.stat either in prototype (the follow_symlinks param is not supported) and some items of result. For details, see https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions

Example:

let s = stat(".")
when defined(windows):
  # _stat's result: st_gid, st_uid is always zero.
  template zero(x) = assert x.int == 0
  zero s.st_gid
  zero s.st_uid
Source   Edit  

Templates

template st_atime(s: Stat): untyped
Source   Edit  
template st_ctime(s: Stat): untyped
Source   Edit  
template st_mtime(s: Stat): untyped
Source   Edit  
template statAttr(path: PathLike | int; attr: untyped): untyped
stat(path).attr Source   Edit