Name
FileAttributes -- get attributes of a file (V6.0)
Synopsis
t = FileAttributes(id)
Library
dos

Function
This function returns a table that contains the attributes of a file that has been opened using OpenFile(). This includes information such as the file time, the full path of the file, protection flags, and more, depending on the host file system.

On return, the table will have the following fields initialized:

Path:
This field will contain a string with the full path to this file.

Size:
This field will be set to the size of the file in bytes.

Flags:
This field will be set to a combination of protection flags of the file. See Protection flags for details.

Time:
This field will receive a string containing the time the file or directory was last modified. The string will always be in the format dd-mmm-yyyy hh:mm:ss. E.g.: 08-Nov-2004 14:32:13.

LastAccessTime:
This field will receive a string containing the time the file or directory was last accessed. This attribute is not supported on AmigaOS.

CreationTime:
This field will receive a string containing the time the file or directory was created. This attribute is only supported on Windows.

Comment:
This field will contain the comment of a file. This is only supported by the Amiga versions.

Streaming:
This field will be set to True if the file is being streamed from a remote source instead of being read from a physical drive.

NoSeek:
This field will be set to True if this file cannot be seeked. This could happen if the file is being streamed from a remote source that only allows sequential reads without any seeking capabilities.

Name:
This field will be set to the name of the file. Normally, this is of not much use since you can of course simply infer the name from the Path field. The only case where this field is really useful is when working with Storage Access Framework (SAF) or MediaStore URIs on Android. Those URIs are often in a custom format which might not contain the file name at all. In that case you can use this field to find out the actual name of the file. See Working with Android URIs for details. (V11.0)

MIMEType:
The MIME type of the file. This is currently only supported on Android and only when working with Storage Access Framework (SAF) or MediaStore URIs. (V11.0)

If you want to query the attributes of a file that is not currently open, use GetFileAttributes() instead. See GetFileAttributes for details.

Inputs
id
identifier of the file to query
Results
t
a table initialized as shown above
Example
OpenFile(1, "test.txt")
t = FileAttributes(1)
Print(t.time)
If t.flags & #FILEATTR_READ_USR
  Print("#FILEATTR_READ_USR is set.")
Else
  Print("#FILEATTR_READ_USR is not set.")
EndIf
The code above examines the file "test.txt" and prints the time it was last modified to the screen. Additionally, it checks if the protection flag #FILEATTR_READ_USR is set.

Show TOC