Name
GetFileAttributes -- get attributes of a file or directory (V3.0)
Synopsis
t = GetFileAttributes(f$[, table])
Deprecated syntax
t = GetFileAttributes(f$[, adapter$])
Function
This function returns a table that contains the attributes of a file or directory. This includes information such as the file time, the full path of the file, protection flags, and more, depending on the host file system. Pass the name of a file or a directory to this command. You can specify an empty string ("") to get information of the current directory.

This function accepts an optional table argument which can be used to pass additional parameters. The following table elements are currently recognized:

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to the adapter set using SetDefaultAdapter(). See Loaders and adapters for details. (V6.0)

UserTags:
This tag can be used to specify additional data that should be passed to file adapters. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.0)

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

Type:
This will be #DOSTYPE_FILE if f$ is a file or #DOSTYPE_DIRECTORY if f$ is a directory.

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

Size:
This field will only be present if f$ is a file. In that case, this field will receive the size of the file in bytes.

Flags:
This field will receive a combination of protection flags of the file or directory. 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.

Virtual:
This field will be set to True if the file you passed to this function is a virtual file, i.e. a file linked to your applet/executable or a file created using DefineVirtualFile(). (V5.2)

If you want to query the attributes of a file that you have opened using OpenFile(), use FileAttributes() instead. See FileAttributes for details.

Inputs
f$
name of file or directory to be examined
table
optional: table containing further options (see above) (V10.0)
Results
t
a table initialized as shown above
Example
t = GetFileAttributes("test.txt")
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