GetFileAttributes -- get attributes of a file or directory (V3.0)
t = GetFileAttributes(f$[, table])
Deprecated syntax
t = GetFileAttributes(f$[, adapter$])
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:

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)

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:

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

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

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.

This field will receive a combination of protection flags of the file or directory. See Protection flags for details.

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.

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

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

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

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.

name of file or directory to be examined
optional: table containing further options (see above) (V10.0)
a table initialized as shown above
t = GetFileAttributes("test.txt")
  Print("#FILEATTR_READ_USR is set.")
  Print("#FILEATTR_READ_USR is not set.")
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