Home  Contents

rawio:stat

Rawio Core4 Lua Event System

SYNOPSIS

  1. stat = rawio.stat(filename)
  2. stat = rawio.stat(fd)
  3. stat = handle:stat()

DESCRIPTION

The functions return information about a file. The first form takes a filename, the second uses an already open numeric file descriptor, while the third accesses an already open file handle.

RETURN VALUE

On success, returns a table with the requested information. On failure, the forms one and two return three values: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library. Form three just returns nil on failure, the error can be retrieved using rawio:lastError().

Not all files have usable values in all fields. Network connections do not have a size, for example.

Field Contents
atime Time of last access, a datetime instance. Not supported by FAT filesystems.
blksize Size of one block in the filesystem.
blocks Number of filesystem blocks used by the file.
ctime Time of last status change, a datetime instance.
mode The filesystem mode bits. (TODO: readable, writable, directory)
mtime Time of last modification, a datetime instance.
nlink Number of hard links.
size The size of the file in bytes.

EXAMPLE

>  > 
st = rawio.stat("/etc/fsexc8x16.lfn") print(st.size)
7832

SEE ALSO