Class Stdio.Stat


This object is used to represent file status information from e.g. file_stat().

It contains the following items usually found in a C struct stat:


File mode (see mknod(2)).


File size in bytes.


User ID of the file's owner.


Group ID of the file's owner.


Time of last access in seconds since 00:00:00 UTC, 1970-01-01.


Time of last data modification.


Time of last file status change.


Time of last access in nanoseconds, added to atime to get sub-second time


Time of last modification in nanoseconds, added to mtime to get sub-second time


Time of last file status change in nanoseconds, added to ctime to get sub-second time


Inode number.


Number of links.


ID of the device containing a directory entry for this file.


ID of the device.

It also contains some items that correspond to the C IS* macros:


Set if the file is a regular file.


Set if the file is a directory.


Set if the file is a symbolic link. Note that symbolic links are normally followed by the stat functions, so this might only be set if you turn that off, e.g. by giving a nonzero second argument to file_stat().


Set if the file is a FIFO (aka named pipe).


Set if the file is a socket.


Set if the file is a character device.


Set if the file is a block device.

There are also some items that provide alternative representations of the above:


The type as a string, can be any of "reg", "dir", "lnk", "fifo", "sock", "chr", "blk", and "unknown".


The file mode encoded as a string in ls -l style, e.g. "drwxr-xr-x".

Note that some items might not exist or have meaningful values on some platforms.

Additionally, the object may be initialized from or casted to an array on the form of a 'traditional' LPC stat-array, and it's also possible to index the object directly with integers as if it were such an array. The stat-array has this format:

int 0

File mode, same as mode.

int 1

If zero or greater, the file is a regular file and this is its size in bytes. If less than zero it gives the type: -2=directory, -3=symlink and -4=device.

int 2

Time of last access, same as atime.

int 3

Time of last data modification, same as mtime.

int 4

Time of last file status change, same as ctime.

int 5

User ID of the file's owner, same as uid.

int 6

Group ID of the file's owner, same as gid.

It's possible to modify the stat struct by assigning values to the items. They essentially work as variables, although some of them affect others, e.g. setting isdir clears isreg and setting mode_string changes many of the other items.

Method create

Stdio.Stat Stdio.Stat(void|object|array stat)


A new Stdio.Stat object can be initialized in two ways:

  • stat is an object, typically another Stdio.Stat. The stat info is copied from the object by getting the values of mode, size, atime, mtime, ctime, uid, gid, dev, ino, nlink, and rdev.

  • stat is a seven element array on the 'traditional' LPC stat-array form (see the class doc).