MTA:Eir/FileSystem/translator/size

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This function queries the size of a filesystem object. The size of a filesystem object is the count of bytes that it logically fills on the storage media.

Syntax

int translator:size ( string filePath )

Arguments

  • filePath: the path to the filesystem object that you want to get the size of

Returns

This function returns the count of bytes that the filesystem object is logically taking on the storage medium, false if filePath is not a valid path in the translator or the filesystem object pointed at by it is not accessible.

Example

Click to collapse [-]
Client

This snippet calculates the size of a resource and prints it to the debug console.

-- Get the handle to the resource instance directory.
local resRoot = fileCreateTranslator( "/" );

-- Calculate the size of every file in it.
local fileSizeCount = 0;

local function fileIteratorSum( filePath )
    fileSizeCount = fileSizeCount + resRoot:size( filePath );
end

-- Iterate through the entire directory tree, including the sub-directories.
resRoot:scanDirEx( "/", "*", nil, fileIteratorSum, true );

-- Output the size to the console.
outputDebugString( "resource size: " .. fileSizeCount );

FileSystem Translator Functions