TrFile_GetDataSize (function reference)

By January 1, 2021May 26th, 2021Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetDataSize
Troi File Plug-in for FileMaker Pro

TrFile_GetDataSize

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.

SyntaxFunction badge

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 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.

Originated in

Troi File Plug-in 1.0

Compatibility

FileMaker Pro 16 to 19

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” (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

DataIn.fmp12

Related functionsFunction badge

TrFile_GetFileSize
TrFile_GetResForkSize
TrFile_SelectFileDialog

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_GetDataSize (filep4224) 2021-0526 08:27:32