Portability Function: Returns detailed information about a file.
Module: USE DFPORT
Syntax
Results:
The result is of type INTEGER(4). The result is zero if the inquiry was successful; otherwise, the error code ENOENT (the specified file could not be found). For a list of other error codes, see IERRNO.
The elements of statb contain the following values:
Element | Description | Notes |
---|---|---|
statb(1) | Device file resides on | Always 0 |
statb(2) | File Inode number | Always 0 |
statb(3) | Access mode of the file | (See following table) |
statb(4) | Number of hard links | Always 1 |
statb(5) | User ID of owner | Always 1 |
statb(6) | Group ID of owner | Always 1 |
statb(7) | Raw device file resides on | Always 0 |
statb(8) | Size of the file in bytes |
|
statb(9) | Time when the file was last accessed | (Only available on non-FAT file systems; undefined on FAT systems) |
statb(10) | Time when the file was last modified |
|
statb(11) | Time of last file status change | Same as stat(10) |
statb(12) | Blocksize | Always 1 |
Times are in the same format returned by the TIME function (number of seconds since 00:00:00 Greenwich mean time, January 1, 1970).
Access mode (the third element of statb) is a bitmap consisting of an IOR of the following constants:
Symbolic name | Constant | Description | Notes |
---|---|---|---|
S_IFMT | O'0170000' | Type of File |
|
S_IFDIR | O'0040000' | Directory |
|
S_IFCHR | O'0020000' | Character Special | Never set |
S_IFBLK | O'0060000' | Block Special | Never set |
S_IFREG | O'0100000' | Regular |
|
S_IFLNK | O'0120000' | Symbolic Link | Never set |
S_IFSOCK | O'0140000' | Socket | Never set |
S_ISUID | O'0004000' | Set User ID on Execution | Never set |
S_ISGID | O'0002000' | Set Group ID on Execution | Never set |
S_ISVTX | O'0001000' | Save Swapped Text | Never set |
S_IRWXU | O'0000700' | Owner's File Permissions |
|
S_IRUSR,
S_IREAD |
O'0000400' | Owner Read Permission | Always true |
S_IWUSR,
S_IWRITE |
O'0000200' | Owner Write Permission |
|
S_IXUSR,
S_IEXEC |
O'0000100' | Owner Execute Permission | Based on file extension (.EXE, .COM, .CMD, or .BAT) |
S_IRWXG | O'0000070' | Group's File Permissions | Same as S_IRWXU |
S_IRGRP | O'0000040' | Group Read Permission | Same as S_IRUSR |
S_IWGRP | O'0000020' | Group Write Permission | Same as S_IWUSR |
S_IXGRP | O'0000010' | Group Execute Permission | Same as S_IXUSR |
S_IRWXO | O'0000007' | Other's File Permissions | Same as S_IRWXU |
S_IROTH | O'0000004' | Other Read Permission | Same as S_IRUSR |
S_IWOTH | O'0000002' | Other Write Permission | Same as S_IWUSR |
S_IXOTH | O'0000001' | Other Execute Permission | Same as S_IXUSR |
STAT returns the same information as FSTAT, but accesses files by name instead of external unit number.
Note: The INQUIRE statement also provides information about file properties.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: INQUIRE, GETFILEINFOQQ
Example
USE DFPORT
CHARACTER*12 file_name
INTEGER(4) info_array(12)
print *, 'Enter file to examine: '
read *, file_name
ISTATUS = STAT (file_name, info_array)
if (.not. istatus) then
print *, info_array
else
print *, 'Error = ',istatus
end if
end