Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

stat

import stat

The module provides constants and functions for interpreting results of file.stat().

The stat API

Every public name in stat, wherever it is declared. Each links to the page that documents it.

NameKindSummary
stat.FILE_ATTRIBUTE_ARCHIVEconstant
stat.FILE_ATTRIBUTE_COMPRESSEDconstant
stat.FILE_ATTRIBUTE_DEVICEconstant
stat.FILE_ATTRIBUTE_DIRECTORYconstant
stat.FILE_ATTRIBUTE_ENCRYPTEDconstant
stat.FILE_ATTRIBUTE_HIDDENconstant
stat.FILE_ATTRIBUTE_INTEGRITY_STREAMconstant
stat.FILE_ATTRIBUTE_NORMALconstant
stat.FILE_ATTRIBUTE_NOT_CONTENT_INDEXEDconstant
stat.FILE_ATTRIBUTE_NO_SCRUB_DATAconstant
stat.FILE_ATTRIBUTE_OFFLINEconstant
stat.FILE_ATTRIBUTE_READONLYconstant
stat.FILE_ATTRIBUTE_REPARSE_POINTconstant
stat.FILE_ATTRIBUTE_SPARSE_FILEconstant
stat.FILE_ATTRIBUTE_SYSTEMconstant
stat.FILE_ATTRIBUTE_TEMPORARYconstant
stat.FILE_ATTRIBUTE_VIRTUALconstant
stat.SF_APPENDconstant
stat.SF_ARCHIVEDconstant
stat.SF_IMMUTABLEconstant
stat.SF_NOUNLINKconstant
stat.SF_SNAPSHOTconstant
stat.ST_ATIMEconstant
stat.ST_CTIMEconstant
stat.ST_DEVconstant
stat.ST_GIDconstant
stat.ST_INOconstant
stat.ST_MODEconstant
stat.ST_MTIMEconstant
stat.ST_NLINKconstant
stat.ST_SIZEconstant
stat.ST_UIDconstant
stat.S_ENFMTconstant
stat.S_IEXECconstant
stat.S_IFBLKconstant
stat.S_IFCHRconstant
stat.S_IFDIRconstant
stat.S_IFDOORconstant
stat.S_IFIFOconstant
stat.S_IFLNKconstant
stat.S_IFMTfunctionReturn the portion of the file’s mode that describes the file type.
stat.S_IFPORTconstant
stat.S_IFREGconstant
stat.S_IFSOCKconstant
stat.S_IFWHTconstant
stat.S_IMODEfunctionReturn the portion of the file’s mode that can be set by file.chmod().
stat.S_IREADconstant
stat.S_IRGRPconstant
stat.S_IROTHconstant
stat.S_IRUSRconstant
stat.S_IRWXGconstant
stat.S_IRWXOconstant
stat.S_IRWXUconstant
stat.S_ISBLKfunctionReturn true if mode is from a block special device file.
stat.S_ISCHRfunctionReturn true if mode is from a character special device file.
stat.S_ISDIRfunctionReturn true if mode is from a directory.
stat.S_ISDOORfunctionReturn true if mode is from a door.
stat.S_ISFIFOfunctionReturn true if mode is from a FIFO (named pipe).
stat.S_ISGIDconstant
stat.S_ISLNKfunctionReturn true if mode is from a symbolic link.
stat.S_ISPORTfunctionReturn true if mode is from an event port.
stat.S_ISREGfunctionReturn true if mode is from a regular file.
stat.S_ISSOCKfunctionReturn true if mode is from a socket.
stat.S_ISUIDconstant
stat.S_ISVTXconstant
stat.S_ISWHTfunctionReturn true if mode is from a whiteout.
stat.S_IWGRPconstant
stat.S_IWOTHconstant
stat.S_IWRITEconstant
stat.S_IWUSRconstant
stat.S_IXGRPconstant
stat.S_IXOTHconstant
stat.S_IXUSRconstant
stat.UF_APPENDconstant
stat.UF_COMPRESSEDconstant
stat.UF_HIDDENconstant
stat.UF_IMMUTABLEconstant
stat.UF_NODUMPconstant
stat.UF_NOUNLINKconstant
stat.UF_OPAQUEconstant
stat.file_modefunctionConvert a file’s mode to a string of the form ‘-rwxrwxrwx’.

Constants

ST_MODE

stat.ST_MODE = 0

ST_INO

stat.ST_INO = 1

ST_DEV

stat.ST_DEV = 2
stat.ST_NLINK = 3

ST_UID

stat.ST_UID = 4

ST_GID

stat.ST_GID = 5

ST_SIZE

stat.ST_SIZE = 6

ST_ATIME

stat.ST_ATIME = 7

ST_MTIME

stat.ST_MTIME = 8

ST_CTIME

stat.ST_CTIME = 9

S_IFDIR

stat.S_IFDIR = 16384

S_IFCHR

stat.S_IFCHR = 8192

S_IFBLK

stat.S_IFBLK = 24576

S_IFREG

stat.S_IFREG = 32768

S_IFIFO

stat.S_IFIFO = 4096

S_IFLNK

stat.S_IFLNK = 40960

S_IFSOCK

stat.S_IFSOCK = 49152

S_IFDOOR

stat.S_IFDOOR = 0

S_IFPORT

stat.S_IFPORT = 0

S_IFWHT

stat.S_IFWHT = 0

S_ISUID

stat.S_ISUID = 2048

S_ISGID

stat.S_ISGID = 1024

S_ENFMT

stat.S_ENFMT

S_ISVTX

stat.S_ISVTX = 512

S_IREAD

stat.S_IREAD = 256

S_IWRITE

stat.S_IWRITE = 128

S_IEXEC

stat.S_IEXEC = 64

S_IRWXU

stat.S_IRWXU = 448

S_IRUSR

stat.S_IRUSR = 256

S_IWUSR

stat.S_IWUSR = 128

S_IXUSR

stat.S_IXUSR = 64

S_IRWXG

stat.S_IRWXG = 56

S_IRGRP

stat.S_IRGRP = 32

S_IWGRP

stat.S_IWGRP = 16

S_IXGRP

stat.S_IXGRP = 8

S_IRWXO

stat.S_IRWXO = 7

S_IROTH

stat.S_IROTH = 4

S_IWOTH

stat.S_IWOTH = 2

S_IXOTH

stat.S_IXOTH = 1

UF_NODUMP

stat.UF_NODUMP = 1

UF_IMMUTABLE

stat.UF_IMMUTABLE = 2

UF_APPEND

stat.UF_APPEND = 4

UF_OPAQUE

stat.UF_OPAQUE = 8
stat.UF_NOUNLINK = 16

UF_COMPRESSED

stat.UF_COMPRESSED = 32

UF_HIDDEN

stat.UF_HIDDEN = 32768

SF_ARCHIVED

stat.SF_ARCHIVED = 65536

SF_IMMUTABLE

stat.SF_IMMUTABLE = 131072

SF_APPEND

stat.SF_APPEND = 262144
stat.SF_NOUNLINK = 1048576

SF_SNAPSHOT

stat.SF_SNAPSHOT = 2097152

FILE_ATTRIBUTE_ARCHIVE

stat.FILE_ATTRIBUTE_ARCHIVE = 32

FILE_ATTRIBUTE_COMPRESSED

stat.FILE_ATTRIBUTE_COMPRESSED = 2048

FILE_ATTRIBUTE_DEVICE

stat.FILE_ATTRIBUTE_DEVICE = 64

FILE_ATTRIBUTE_DIRECTORY

stat.FILE_ATTRIBUTE_DIRECTORY = 16

FILE_ATTRIBUTE_ENCRYPTED

stat.FILE_ATTRIBUTE_ENCRYPTED = 16384

FILE_ATTRIBUTE_HIDDEN

stat.FILE_ATTRIBUTE_HIDDEN = 2

FILE_ATTRIBUTE_INTEGRITY_STREAM

stat.FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768

FILE_ATTRIBUTE_NORMAL

stat.FILE_ATTRIBUTE_NORMAL = 128

FILE_ATTRIBUTE_NOT_CONTENT_INDEXED

stat.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192

FILE_ATTRIBUTE_NO_SCRUB_DATA

stat.FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072

FILE_ATTRIBUTE_OFFLINE

stat.FILE_ATTRIBUTE_OFFLINE = 4096

FILE_ATTRIBUTE_READONLY

stat.FILE_ATTRIBUTE_READONLY = 1

FILE_ATTRIBUTE_REPARSE_POINT

stat.FILE_ATTRIBUTE_REPARSE_POINT = 1024

FILE_ATTRIBUTE_SPARSE_FILE

stat.FILE_ATTRIBUTE_SPARSE_FILE = 512

FILE_ATTRIBUTE_SYSTEM

stat.FILE_ATTRIBUTE_SYSTEM = 4

FILE_ATTRIBUTE_TEMPORARY

stat.FILE_ATTRIBUTE_TEMPORARY = 256

FILE_ATTRIBUTE_VIRTUAL

stat.FILE_ATTRIBUTE_VIRTUAL = 65536

Functions

S_IMODE()

stat.S_IMODE(mode: number) -> number

Return the portion of the file’s mode that can be set by file.chmod().

Parameters

  • mode (number)

Returns number

S_IFMT()

stat.S_IFMT(mode: number) -> number

Return the portion of the file’s mode that describes the file type.

Parameters

  • mode (number)

Returns number

S_ISDIR()

stat.S_ISDIR(mode: number) -> number

Return true if mode is from a directory.

Parameters

  • mode (number)

Returns number

S_ISCHR()

stat.S_ISCHR(mode: number) -> number

Return true if mode is from a character special device file.

Parameters

  • mode (number)

Returns number

S_ISBLK()

stat.S_ISBLK(mode: number) -> number

Return true if mode is from a block special device file.

Parameters

  • mode (number)

Returns number

S_ISREG()

stat.S_ISREG(mode: number) -> number

Return true if mode is from a regular file.

Parameters

  • mode (number)

Returns number

S_ISFIFO()

stat.S_ISFIFO(mode: number) -> number

Return true if mode is from a FIFO (named pipe).

Parameters

  • mode (number)

Returns number

S_ISLNK()

stat.S_ISLNK(mode: number) -> number

Return true if mode is from a symbolic link.

Parameters

  • mode (number)

Returns number

S_ISSOCK()

stat.S_ISSOCK(mode: number) -> number

Return true if mode is from a socket.

Parameters

  • mode (number)

Returns number

S_ISDOOR()

stat.S_ISDOOR(mode: number) -> number

Return true if mode is from a door.

Parameters

  • mode (number)

Returns number

S_ISPORT()

stat.S_ISPORT(mode: number) -> number

Return true if mode is from an event port.

Parameters

  • mode (number)

Returns number

S_ISWHT()

stat.S_ISWHT(mode: number) -> number

Return true if mode is from a whiteout.

Parameters

  • mode (number)

Returns number

file_mode()

stat.file_mode(mode: number) -> string

Convert a file’s mode to a string of the form ‘-rwxrwxrwx’.

Parameters

  • mode (number)

Returns string


2022, Richard Ore and The Zuri Contributors