Modules/FileSystem/translator/relPathRoot: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ 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== <syntaxhighlight lang="lua"> string translator:relPathRoot ( string path ) </syntaxhighlight> ==Arguments== *'''path:''' the path that should be transformed into a relative path; can be nil to return the '''null path''' ==Returns== This func...") |
No edit summary |
||
Line 1: | Line 1: | ||
<pageclass class="#3c82c8" subcaption="Translator function"></pageclass> | |||
__NOTOC__ | __NOTOC__ | ||
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. | 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. |
Latest revision as of 03:28, 23 January 2022
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 );