MTA:Eir/FileSystem/createFilesystemInterface: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function creates a FileSystem access point. An access point is your personal instance of the | This function creates a FileSystem access point. An access point is your personal instance of the 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 module, it is highly suggested to restrict access to this function to priviledged resources!''' | |||
==Syntax== | ==Syntax== | ||
Line 10: | Line 12: | ||
This function returns the table that denotes the '''FileSystem module namespace'''. | This function returns the table that denotes the '''FileSystem module namespace'''. | ||
==Example== | |||
<section name="Server" class="server" show="true"> | |||
This snippet sets up access to your resource in a simple server-side resource environment when using the FileSystem module. | |||
<syntaxhighlight lang="lua"> | |||
-- 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! | |||
</syntaxhighlight> | |||
</section> | |||
{{:MTA:Eir/FileSystem/functions}} | {{:MTA:Eir/FileSystem/functions}} |
Latest revision as of 21:50, 16 January 2022
This function creates a FileSystem access point. An access point is your personal instance of the 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 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
- 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)