MTA:Eir/FileSystem/createFilesystemInterface

From Multi Theft Auto: Wiki
Revision as of 00:45, 29 January 2014 by The GTA (talk | contribs)
Jump to navigation Jump to search

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.

Syntax

table createFilesystemInterface ()

Returns

This function returns the table that denotes the FileSystem module namespace.

Example

Click to collapse [-]
Client

This 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 is 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

FileSystem Archive Translator Functions

FileSystem File Functions