From Multi Theft Auto: Wiki

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.


int translator.size ( string filePath )


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


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.


Click to collapse [-]

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 );

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