FSTAT

Portability Function: Returns detailed information about a file specified by a external unit number.

Module: USE DFPORT

Syntax

result = FSTAT (lunit, statb)

lunit
(Input) INTEGER(4). External unit number of the file to examine.


statb
(Output) INTEGER(4). One-dimensional array with a size of 12. The following table describes the elements of the array:


statb element Return value
statb(1) Device the file resides on (always 0)
statb(2) Inode number (always 0)
statb(3) File type, attributes, and access control information (see the following table)
statb(4) Number of 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 1)
statb(8) The size of the file in bytes
statb(9) The time of last access (only available on non-FAT file systems; same as statb(10) on FAT systems.
statb(10) The time of last modification
statb(11) The time of last status change (same as statb(10))
statb(12) Block size (always 1)

Results:

The result is of type INTEGER(4). The result is zero if successful; otherwise, returns an error code equal to EINVAL (lunit is not a valid unit number, or is not open).

Mode is a bitmap consisting of an IOR of the following constants (the module DFPORT supplies parameters with the symbolic names given):

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 Set if S_IREAD is set
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's 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

Time values are returned as number of seconds since 0:00:00 Greenwich mean time, January 1, 1970.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: INQUIRE

Example

USE DFPORT
integer(4) statarray(12), istat
OPEN (unit=1,file='datfile.dat')
ISTAT = FSTAT (1, statarray)
if (.NOT. istat) then
    print *, statarray
end if