MTA:Eir/FileSystem/createTranslator
Jump to navigation
Jump to search
This function creates a FileSystem translator. A FileSystem translator represents a directory on a real or virtual filesystem. Through translators you get access to the files that reside in their directory trees. The translator returned by this function usually represents an OS filesystem directory.
Syntax
translator fsnamespace.createTranslator( string rootPath )
Arguments
- rootPath: the absolute path to the directory that you want access to.
Returns
This function returns the FileSystem translator that grants access to files in the requested directory.
Example
Click to collapse [-]
ClientThis snippet links all directories inside of your resource instance folder using translators and lists them in a dictionary under their name.
-- Dictionary that will contain all directory links of our resource. local dirs = {}; -- Create a translator to the resource root. local resRoot = fileCreateTranslator( "/" ); local function dirIterator( dirPath ) -- get the simple name of this directory. -- the simple name is the path relative to resRoot without the '/' local simpleName = resRoot.relPathRoot( dirPath ); simpleName = string.sub( simpleName, 1, #simpleName - 1 ); -- link this directory and set it into our dirs dictionary. -- we should always pass the absolute directory to this function. local translator = fileCreateTranslator( dirPath ); dirs[simpleName] = translator; end local function fileIterator( filePath ) -- do nothing. return; end resRoot.scanDirEx( "/", "*", dirIterator, fileIterator, false );
FileSystem Library Functions
- createFilesystemInterface (module only)
FileSystem Namespace Functions
- createTranslator
- createRAMDisk
- createMemoryFile
- createFileIterative
- createArchiveTranslator (not module)
- createZIPArchive (not module)
- copyFile
- copyStream
- copyStreamCount
- pathToFilename
- streamCompare
- topointer
- type
- setDoBufferAllRaw
- getDoBufferAllRaw
FileSystem Translator Functions
- open
- exists
- createDir
- chdir
- delete
- copy
- rename
- size
- stat
- relPath
- relPathRoot
- absPath
- absPathRoot
- scanDir
- scanDirEx
- getDirs
- getFiles
- setOutbreakEnabled
- getOutbreakEnabled
- setPathProcessingMode
- getPathProcessingMode
FileSystem Archive Translator Functions
- save (not module)