fileinfo — Provides information about a file
[x,ierr] = fileinfo(files)
a character string or a string column vector, file pathname
an integer vector of size 13 containing information or an empty matrix if file does not exist.
if 'files' is a a string column vector, x wil be a matrix of size m x 13.
If a filename does not exist , it will return as output information a line of size 13 with Nan in each element of this line.
error indicator, 0, if no error has occured
x = fileinfo(file) returns
The file size
The file mode (decimal value).
The user id
The group id
The device number
The date of last modification
The date of last change
The date of last access
The device type (if inode device)
The blocksize for filesystem I/O (always 0 on Windows)
The number of blocks allocated (always 0 on Windows)
The inode
The number of hard links
This function is an interface to the C function stat.
Permissions are typically specified as octal numbers : dec2oct(x(2)) to convert
Numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Any omitted digits are assumed to be leading zeros. The first digit selects the set user ID (4) and set group ID (2) and sticky (1) attributes. The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1); the third selects permissions for other users in the file's group, with the same values; and the fourth for other users not in the file's group, with the same values.
w = fileinfo(SCI+'/etc/scilab.start') // file permission dec2oct(w(2)) // file date getdate(w(6)) // Checks write permission on a file w = fileinfo(SCI+'/etc/scilab.start') S_IWRITE = 128; // mask write permission S_IEXEC = 64; // mask exec permission S_IREAD = 256; // mask read permission S_IFCHR = 8192; // mask directory permission if ( bitand( w(2), S_IWRITE ) <> 0) then disp('WRITE PERMISSION on this file.'); else disp('NO WRITE PERMISSION on this file.'); end FILES = [SCI;SCIHOME;'not_exist_file';TMPDIR] [X,ERRS] = fileinfo(FILES)