From Multi Theft Auto: Wiki
Jump to: navigation, search

This function creates a directory inside of a translator directory hierarchy.


bool translator.createDir ( string dirPath )


  • dirPath: a path to a directory that should be created


This function returns true if the given path is a valid directory path relative to the translator, false otherwise.


Click to collapse [-]

This 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

FileSystem Translator Functions