MTA:Eir/FileSystem/translator/size

From Multi Theft Auto: Wiki
Revision as of 12:15, 29 January 2014 by The GTA (talk | contribs)
Jump to navigation Jump to search

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