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

Change language to:
Français - 日本語 - Português

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

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

fileinfo

Provides information about a file

Calling Sequence

[x,ierr] = fileinfo(files)

Arguments

files

a character string or a string column vector, file pathname

x

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.

ierr

error indicator, 0, if no error has occured

Description

x = fileinfo(file) returns

x(1)

The file size

x(2)

The file mode (decimal value).

x(3)

The user id

x(4)

The group id

x(5)

The device number

x(6)

The date of last modification

x(7)

The date of last change

x(8)

The date of last access

x(9)

The device type (if inode device)

x(10)

The blocksize for filesystem I/O (always 0 on Windows)

x(11)

The number of blocks allocated (always 0 on Windows)

x(12)

The inode

x(13)

The number of hard links

Reference

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.

Examples

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)

Authors

S. Steer INRIA

A.C

<< fileext Files : Input/Output functions fileparts >>

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:
Wed Jan 26 16:23:43 CET 2011