TrFile_GetDataSize |
Returns the size of the data for the file specified by the filePath. The size returns the actual number of bytes used in the file (not the size on disk).
Syntax
TrFile_GetDataSize ( switches ; filePath )
Parameters
switches | not used, reserved for future use. Leave blank or put "-Unused" |
filePath | the path to the file |
Returned Result
Data type returned
Number
Result
The size (in bytes) of the data of the file specified. On macOS a file can have a data fork and also a resource fork. On macOS this function returns the size of the data fork only.
Originated in
Troi File Plug-in 1.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
See also the functions TrFile_GetFileSize and TrFile_GetResForkSize.
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.
Example
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.
Example 2
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” (macOS). In a script add the following script step:
Set Field [ gSize ; TrFile_GetDataSize ( "-Unused" ; gFileSpec ) ]
This will fill gSize with the size of the data.
Used in example file
DataIn.fmp12
Related functions
TrFile_GetContents |
TrFile_GetFileSize |
TrFile_GetResForkSize |
TrFile_SelectFileDialog |
Related topics
Troi File Plug-in online help (overview)