MTA:Eir/FileSystem/createFilesystemInterface
From Multi Theft Auto: Wiki
This function creates a FileSystem access point. An access point is your personal instance of the MTA:Eir FileSystem. The table returned by this function is the module namespace. There are no limits as to how many access points can be live at a time.
When using the fileSystem.dll module, it is highly suggested to restrict access to this function to priviledged resources!
Syntax
table createFilesystemInterface ()
Returns
This function returns the table that denotes the FileSystem module namespace.
Example
Click to collapse [-]
ServerThis snippet sets up access to your resource in a simple server-side resource environment when using the FileSystem module.
-- Create the interface. local fsys = createFilesystemInterface(); -- Make sure we have access to the module. -- Access could be blocked by acl.xml priviledges. if not ( fsys ) then outputDebugString( "could not create FileSystem interface" ); return false; end -- Assume the resource is located inside a folder in the deathmatch resources directory. -- Then we create a raw OS filesystem link to it. local resRoot = fsys.createTranslator( "mods/deathmatch/resources/" .. getResourceName(resource) .. "/" ); -- Check that we have access (i.e. passed OS priviledges test) for this folder. -- Will fail if the resource is not inside a folder in the deathmatch resources directory. if not ( resRoot ) then outputDebugString( "cannot link resource instance directory" ); return false; end -- Open the "meta.xml" file. local metaFile = resRoot.open( "meta.xml", "rb" ); -- Success!
FileSystem Library Functions
FileSystem Namespace Functions
FileSystem Translator Functions
- open
- exists
- createDir
- chdir
- delete
- copy
- rename
- size
- stat
- relPath
- relPathRoot
- absPath
- absPathRoot
- scanDir
- scanDirEx
- getDirs
- getFiles