Modules/FileSystem/translator/size: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ 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== <syntaxhighlight lang="lua"> int translator:size ( string filePath ) </syntaxhighlight> ==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 sto...") |
No edit summary |
||
Line 1: | Line 1: | ||
<pageclass class="#3c82c8" subcaption="Translator function"></pageclass> | |||
__NOTOC__ | __NOTOC__ | ||
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. | 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. |
Latest revision as of 03:27, 23 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 );