The FILE_INFO function returns status information about a specified file or files.

Examples


To get information for dist.pro within the IDL library:

HELP,/STRUCTURE, FILE_INFO(FILEPATH('dist.pro', $
    SUBDIRECTORY = 'lib'))

Executing the above command will produce output similar to:

** Structure FILE_INFO, 21 tags, length=72:
NAME                STRING   '/usr/local/idl/lib/dist.pro'
EXISTS              BYTE         1
READ                BYTE         1
WRITE               BYTE         0
EXECUTE             BYTE         0
REGULAR             BYTE         1
DIRECTORY           BYTE         0
BLOCK_SPECIAL       BYTE         0
CHARACTER_SPECIAL   BYTE         0
NAMED_PIPE          BYTE         0
SETGID              BYTE         0
SETUID              BYTE         0
SOCKET              BYTE         0
STICKY_BIT          BYTE         0
SYMLINK             BYTE         0
DANGLING_SYMLINK    BYTE         0
MODE                LONG         438
ATIME               LONG64       970241431
CTIME               LONG64       970241595
MTIME               LONG64       969980845
SIZE                LONG64       1717

Syntax


Result = FILE_INFO(Path [, /NOEXPAND_PATH] )

Return Value


The FILE_INFO function returns a structure expression of type FILE_INFO containing status information about the specified file or files. The result will contain one structure for each element in the Path argument.

Fields of the FILE_INFO Structure

The FILE_INFO structure consists of the following fields:

Field Name

Meaning

NAME

The name of the file.

EXISTS

True (1) if the file exists. False (0) if it does not exist.

READ

True (1) if the file is exists and is readable by the user. False (0) if it is not readable.

WRITE

True (1) if the file exists and is writable by the user. False (0) if it is not writable.

EXECUTE

True (1) if the file exists and is executable by the user. False (0) if it is not executable. The source of this information differs between operating systems:

UNIX: IDL checks the execute bit maintained by the operating system.

Microsoft Windows: The determination is made on the basis of the file name extension (e.g. .exe).

REGULAR

True (1) if the file exists and is a regular disk file and not a directory, pipe, socket, or other special file type. False (0) if it is not a regular disk file (it maybe a directory, pipe, socket, or other special file type).

DIRECTORY

True (1) if the file exists and is a directory. False (0) if it is not a directory.

BLOCK_SPECIAL

True (1) if the file exists and is a UNIX block special device. On non-UNIX operating systems, this field will always be False (0).

CHARACTER_SPECIAL

True (1) if the file exists and is a UNIX character special device. On non-UNIX operating systems, this field will always be False (0).

NAMED_PIPE

True (1) if the file exists and is a UNIX named pipe (fifo) device. On non-UNIX operating systems, this field will always be False (0).

SETGID

True (1) if the file exists and has its Set-Group-ID bit set. On non-UNIX operating systems, this field will always be False (0).

SETUID

True (1) if the file exists and has its Set-User-ID bit set. On non-UNIX operating systems, this field will always be False (0).

SOCKET

True (1) if the file exists and is a UNIX domain socket. On non-UNIX operating systems, this field will always be False (0).

STICKY_BIT

True (1) if the file exists and has its sticky bit set. On non-UNIX operating systems, this field will always be False (0).

SYMLINK

True (1) if the file exists and is a UNIX symbolic link. On non-UNIX operating systems, this field will always be False (0).

DANGLING_SYMLINK

True (1) if the file exists and is a UNIX symbolic link that points at a non-existent file. On non-UNIX operating systems, this field will always be False (0).

MODE File permissions in octal notation. See Numeric Notation on Wikipedia.org for more information.

ATIME, CTIME, MTIME

The date of last access, date of file status change, and date of last modification given in seconds since 1 January 1970 UTC. Use the SYSTIME function to convert these dates into a textual representation. On Windows platforms the CTIME field will contain the file creation time. On Unix platforms the CTIME field will contain the time of the last file status change.

Note: Some file systems do not maintain all of these dates (e.g. MS DOS FAT file systems), and may return 0. On some non-UNIX operating systems, access time is not maintained, and ATIME and MTIME will always return the same date.

Tip: If you only need the file modification time, it is faster to use the FILE_MODTIME function instead.

SIZE

The current length of the file in bytes. If Path is not to a regular file (possibly to a directory, pipe, socket, or other special file type), the value of SIZE will not contain any useful information.

Arguments


Path

A string or string array containing the path or paths to the file or files about which information is required.

Note: Windows platforms have a file name length limit of 260 characters, while Unix platforms have a limit of 1024 characters. File names longer than this limit will return a structure with the EXISTS field set to zero.

Note: If the file pointed to by Path is currently open, use FSTAT to query for its info. FILE_INFO does not always obtain information on changes that have occurred in a file that is currently open. FSTAT, however, maintains current information on files it opens.

Keywords


NOEXPAND_PATH

If specified, FILE_INFO uses Path exactly as specified, without applying the usual file path expansion.

Version History


5.5

Introduced

See Also


FILE_MODTIME, FILE_TEST,  FSTAT, General File Access