Class fs.StatBuf

An object holding various attributes of a file.

Returned by fs.stat, ui.Panel:get_current, and others.

This object is a wrapper around C’s struct stat. The name of the class derives from the name such variables are often given in C.

Fields

atime Time of last access.
blksize Preferred block size for filesystem I/O.
blocks Number of 512B blocks allocated.
ctime Time of last status change.
dev ID of device containing file.
gid Group ID of owner.
ino inode number.
mode Permission bits plus file-type bits.
mtime Time of last modification.
nlink Number of links.
perm The permission bits of the file.
rdev Device ID (if special file).
size File size.
type The type of the file.
uid User ID of owner.

Methods

extract() Converts a fs.StatBuf to a table.


Fields

atime
Time of last access.

(On modern systems its meaning is somewhat altered for performance reasons.)

blksize
Preferred block size for filesystem I/O.
blocks
Number of 512B blocks allocated.
ctime
Time of last status change.
dev
ID of device containing file.
gid
Group ID of owner.
ino
inode number.
mode
Permission bits plus file-type bits.

Since it’s not trivial to decipher this field in Lua, it’s broken down for you into two “easy” fields: perm and type.

The “easy” fields work in the other direction too: When you need to conjure up a StatBuf you can provide only the “easy” field(s) (if both an “easy” field and mode are given, the “easy” field takes precedence).

mtime
Time of last modification.
nlink
Number of links.
perm
The permission bits of the file.
rdev
Device ID (if special file).
size
File size.
type

The type of the file.

It’s one of:

  • “regular”
  • “directory”
  • “link”
  • “socket”
  • “fifo”
  • “character device”
  • “block device”
uid
User ID of owner.

Methods

extract()

Converts a fs.StatBuf to a table.

This method extracts each and every field out of a fs.StatBuf, into a table. This is useful for debugging mainly, not for much else.

-- Show the stat() of the current file.
ui.Panel.bind('C-f', function(pnl)
  local filename, statbuf = pnl:get_current()
  devel.view( statbuf:extract() )
end)
generated by LDoc 1.4.3 Last updated 2016-08-23 17:29:40