MTA:Eir/FileSystem/translator/createDir: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 21: | Line 21: | ||
-- Create some folders. | -- Create some folders. | ||
resRoot | resRoot:createDir( "theDirectory/" ); -- successfully creates "theDirectory" folder | ||
resRoot | resRoot:createDir( "secondDirectory" ); -- fails to create "secondDirectory" as intended, because it is not a valid dirPath | ||
resRoot | resRoot:createDir( "thirdDirectory/fourthDirectory/documents/" ); -- successfully creates three directories at a time | ||
resRoot | resRoot:createDir( "../hax/" ); -- fails to create "hax" directory, because the path is not relative to the translator anymore | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
{{:MTA:Eir/FileSystem/translator/functions}} | {{:MTA:Eir/FileSystem/translator/functions}} |
Latest revision as of 23:21, 16 January 2022
This function creates a directory inside of a translator directory hierarchy.
Syntax
bool translator:createDir ( string dirPath )
Arguments
- dirPath: a path to a directory that should be created
Returns
This function returns true if the given path is a valid directory path relative to the translator, false otherwise.
Example
Click to collapse [-]
ClientThis snippet creates a folder hierarchy.
-- Create a generic resource root translator local resRoot = fileCreateTranslator( "/" ); -- Create some folders. resRoot:createDir( "theDirectory/" ); -- successfully creates "theDirectory" folder resRoot:createDir( "secondDirectory" ); -- fails to create "secondDirectory" as intended, because it is not a valid dirPath resRoot:createDir( "thirdDirectory/fourthDirectory/documents/" ); -- successfully creates three directories at a time resRoot:createDir( "../hax/" ); -- fails to create "hax" directory, because the path is not relative to the translator anymore