MTA:Eir/FileSystem/translator/relPathRoot
From Multi Theft Auto: Wiki
This function transform a path that is passed to it into a path that is relative to the translators root directory. The path must be accessible from the translator. The path can either be absolute or relative.
Syntax
string translator.relPathRoot ( string path )
Arguments
- path: the path that should be transformed into a relative path; can be nil to return the null path
Returns
This function returns the relative version of the path that is passed to it, false if the specified path is not accessible by the translator.
Example
Click to collapse [-]
ClientThis snippet returns the relative-to-root version of a translator relative path.
-- Create a generic file translator to the resource instance directory. local resRoot = fileCreateTranslator( "/" ); -- Change into another directory. resRoot.createDir( "myDir/" ); resRoot.chdir( "myDir/" ); -- Output the path relative to the current directory and relative to the translator root directory. local thePath = "someDir/../myFile.txt"; local relativeToCurrent = resRoot.relPath( thePath ); local relativeToRoot = resRoot.relPathRoot( thePath ); outputChatBox( "input-path: " .. thePath ); outputChatBox( "relative-to-current: " .. relativeToCurrent ); outputChatBox( "relative-to-root: " .. relativeToRoot );