MTA:Eir/FileSystem/translator/size: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int translator | int translator:size ( string filePath ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 24: | Line 24: | ||
local function fileIteratorSum( filePath ) | local function fileIteratorSum( filePath ) | ||
fileSizeCount = fileSizeCount + resRoot | fileSizeCount = fileSizeCount + resRoot:size( filePath ); | ||
end | end | ||
-- Iterate through the entire directory tree, including the sub-directories. | -- Iterate through the entire directory tree, including the sub-directories. | ||
resRoot | resRoot:scanDirEx( "/", "*", nil, fileIteratorSum, true ); | ||
-- Output the size to the console. | -- Output the size to the console. |
Latest revision as of 23:25, 16 January 2022
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 [-]
ClientThis 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 );