TrFile_GetFileAttribute (function reference)

By May 1, 2017 May 22nd, 2019 Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetFileAttribute
Troi File Plug-in for FileMaker Pro

TrFile_GetFileAttribute

Returns an attribute of the file specified by the filePath.

SyntaxFunction badge

TrFile_GetFileAttribute ( switches ; filePath )

Parameters

switchesthis determines the attribute that is returned
filePaththe path to the file

Switches

switches can be one of the following:

-LockAttrreturn number indicating whether the file is locked (Mac) or Read-only (Windows)
-HiddenAttrreturn number indicating whether the file is hidden (invisible)
-ArchiveAttrreturn number indicating whether the file’s archive bit is set (Windows only)
-LabelNumAttrreturn number indicating the label of a file (Mac OS only)
-FindercommentAttrreturn the finder comment of a file (Mac OS only)
-PackageFolderAttrreturn number indicating whether the file is a package folder (Mac OS only)

Returned Result

Data type returned

Text

Result

The returned result is the requested attribute of the file.

Result for switch “-LockAttr”:
Returns 1 for a locked file and 0 for an unlocked file. On Windows it returns the equivalent “Read-only”-attribute: 1 if the file is a Read-only file and 0 otherwise.

Result for switch “-HiddenAttr”:
Returns 1 if the file is hidden and 0 otherwise.

Result for switch “-ArchiveAttr”:
Returns 1 if the file’s archive bit is set and 0 otherwise. This bit is only available on Windows. On Mac OS this switch always returns 0.

Result for switch “-LabelNumAttr”:
Returns a number between 0 (=no label) and 7. This attribute is only available on Mac OS. On Windows this switch always returns 0.

Result for switch “-FindercommentAttr”:
Returns the finder comment, which is visible with the Get Info command in the Mac OS Finder. On Windows this switch always returns “”.

Result for switch “-PackageFolderAttr”:
Returns 1 if the item is a package folder and 0 otherwise. For example all Mac OS X applications are package folders. This attribute is only available on Mac OS. On Windows this switch always returns 0.

Note that also an error code might be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:

$$-43fnfErrFile not found, check if the path is valid
$$-1genericErrThe file could not be found (older versions of the plug-in)

Other errors may be returned.

Originated in

Troi File Plug-in 2.0

Compatibility

FileMaker Pro 14 to 18

Considerations

The switch “-PackageFolderAttr” can be used to determine if a result of the drag and drop action is a package.
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.

Example

Set Field [ result ; TrFile_GetFileAttribute ( "-LockAttr" ; "C:\test.doc" ) ]

The result will be 1 if the file is Read-Only and 0 otherwise.

Example 2

We assume that in your FileMaker file the following fields are defined:

    locked		text
    filePath		text

“filePath” should contain the path to an existing file, for example “D:\Out.txt” (Windows) or “Mac HD:Out.txt” (Mac). In a script add the following script step:

Set Field [ locked ; TrFile_GetFileAttribute ( "-LockAttr" ; filePath ) ]

This will get the locked status (1 or 0) of the file into the field “locked”.

Related functionsFunction badge

TrFile_DragAndDrop
TrFile_IsFree
TrFile_SetFileAttribute

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 14 to 18 –> TrFile_GetFileAttribute (filep4234) 2019-0522 16:43:42