Returns the size of the data for the file specified by the filePath. The size indicates the actual number of bytes used by the data fork.
TrFile_GetDataSize ( switches ; filePath )
|switches||not used, reserved for future use. Leave blank or put "-Unused"|
|filePath||the path to the file|
Data type returned
The size (in bytes) of the data of the file specified. On Mac a file can have a data fork and also a resource fork. On macOS this function returns the size of the data fork only.
Troi File Plug-in 1.0
FileMaker Pro 16 to 19
See also the functions TrFile_GetFileSize and TrFile_GetResForkSize.
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.
Assume there is a file “Read me” with the text “Hello!” in it. Then:
Set Field [ MyTextField ; TrFile_GetDataSize ( "-Unused" ; "Disk:Read me" ) ]
returns 6, which is the size of the data in the file. The total file size may be bigger.
We assume that in your FileMaker file the following fields are defined:
gFileSpec Global, text gSize Global, number
gFileSpec should contain the path to an existing file, for example “D:\Readme.txt” (Windows) or “Mac HD:Readme.txt” (Mac). In a script add the following scriptstep:
Set Field [ gSize ; TrFile_GetDataSize ( "-Unused" ; gFileSpec ) ]
This will fill gSize with the size of the data.
Used in example file