MTA:Eir/FileSystem/translator/stat: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ This function queries common information about a filesystem object and returns it as a dictionary. Example of its return value: <syntaxhighlight lang="lua"> { accessTime = 139099795...")
 
mNo edit summary
 
Line 12: Line 12:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
dictionary translator.stat ( string filePath )
dictionary translator:stat ( string filePath )
</syntaxhighlight>
</syntaxhighlight>


Line 29: Line 29:


-- Get the information of this script file.
-- Get the information of this script file.
local scriptStats = resRoot.stat( "thisScript.lua" );
local scriptStats = resRoot:stat( "thisScript.lua" );


-- todo: use this information somehow.
-- todo: use this information somehow.

Latest revision as of 23:25, 16 January 2022

This function queries common information about a filesystem object and returns it as a dictionary. Example of its return value:

{
    accessTime = 1390997951, -- OS specific time information
    creationTime = 1381999749, -- OS specific time information
    modTime = 1381872826, -- OS specific time information
    size = 1441280, -- size of the filesystem object in bytes
};

Syntax

dictionary translator:stat ( string filePath )

Arguments

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

Returns

This function returns a statistics structure of the filesystem object pointed at by filePath, 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 returns information about the currently running script. It can be used to know when the script has been updated by MTA.

-- Grab a generic translator of resource instance directory.
local resRoot = fileCreateTranslator( "/" );

-- Get the information of this script file.
local scriptStats = resRoot:stat( "thisScript.lua" );

-- todo: use this information somehow.

FileSystem Translator Functions