Navigation

Operators and Keywords

Function List:

C++ API

: [info, err, msg] = stat (file)
: [info, err, msg] = stat (fid)
: [info, err, msg] = lstat (file)
: [info, err, msg] = lstat (fid)

Return a structure info containing the following information about file or file identifier fid.

dev

ID of device containing a directory entry for this file.

ino

File number of the file.

mode

File mode, as an integer. Use the functions S_ISREG, S_ISDIR, S_ISCHR, S_ISBLK, S_ISFIFO, S_ISLNK, or S_ISSOCK to extract information from this value.

modestr

File mode, as a string of ten letters or dashes as would be returned by ls -l.

nlink

Number of links.

uid

User ID of file’s owner.

gid

Group ID of file’s group.

rdev

ID of device for block or character special files.

size

Size in bytes.

atime

Time of last access in the same form as time values returned from time. See ‘Timing Utilities’.

mtime

Time of last modification in the same form as time values returned from time. See ‘Timing Utilities’.

ctime

Time of last file status change in the same form as time values returned from time. See ‘Timing Utilities’.

blksize

Size of blocks in the file.

blocks

Number of blocks allocated for file.

If the call is successful err is 0 and msg is an empty string. If the file does not exist, or some other error occurs, info is an empty matrix, err is -1, and msg contains the corresponding system error message.

If file is a symbolic link, stat will return information about the actual file that is referenced by the link. Use lstat if you want information about the symbolic link itself.

For example:

[info, err, msg] = stat ("/vmlinuz")
 ⇒ info =
    {
      atime = 855399756
      rdev = 0
      ctime = 847219094
      uid = 0
      size = 389218
      blksize = 4096
      mtime = 847219094
      gid = 6
      nlink = 1
      blocks = 768
      mode = -rw-r--r--
      modestr = -rw-r--r--
      ino = 9316
      dev = 2049
    }
 ⇒ err = 0
 ⇒ msg =

See also: lstat, ls, dir.

Package: octave