Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Files : Input/Output functions > fileinfo


provides information about a file

Calling Sequence

[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 string column vector, x will 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 occurred.


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 data modification


The date of last file status 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.

So, to check permissions, it is necessary to use masks. Let us take an example: In octal, x(2)=1664, so first digit corresponds to sticky attributes. The second indicates that file owner has permission of writing and reading. It is the same for other users in the file's group. Finally, others users has just right to read. To apply a mask, it is simpler to look at this octal in binary. So: x(2)= 1 110 110 100. To check if the owner has write permission, we must take a look at the second triplet: 110 and compare it with write permission 010. So, the operation is: 110 000 000 & 010 000 000. If result is not null (it is the case here), owner has write permission.


w = fileinfo(SCI+'/etc/scilab.start')
// file permission
// file date

// Permissions
S_IWRITE = 128; // mask write permission
S_IEXEC = 64; // mask exec permission
S_IREAD = 256; // mask read permission
S_IFCHR = 8192; // mask directory permission

// Checks write permission
if ( bitand( w(2), S_IWRITE ) <> 0) then
 disp('WRITE PERMISSION on this file.');
 disp('NO WRITE PERMISSION on this file.');
// Checks read permission
if ( bitand( w(2), S_IREAD ) <> 0) then
 disp('READ PERMISSION on this file.');
 disp('NO READ PERMISSION on this file.');

FILES = [SCI;SCIHOME;'not_exist_file';TMPDIR]
[X,ERRS] = fileinfo(FILES)

See Also

  • getdate — get date and time information
  • file — file management
  • dispfiles — displays opened files properties
  • newest — returns newest file of a set of files
  • isdir — checks if argument is a directory path
Report an issue
<< dispfiles Files : Input/Output functions findfiles >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:06:54 CEST 2014