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

This function creates a FileSystem archive translator. A FileSystem archive translator is a virtual FileSystem that grants access to the contents of archives. You can browse archives the same way as you would with native OS directories. The archive implementations usually cache their operations inside of the OS temp directory.

Currently, only .zip archives are supported.


atranslator fsnamespace.createArchiveTranslator ( file fileHandle )


  • fileHandle: a MTA:Eir FileSystem file/stream class that contains the archive.


This function returns the FileSystem translator that grants access to contents of an archive.


This function is currently unavailable in the fileSystem.dll module.


Click to collapse [-]

This snippet lists the contents of a .zip archive.

-- Opens the file link to our .zip archive.
-- The input fileStream can actually be any file/stream class that is exported to the script.
-- The implementation is allowed to throw exceptions if a file/stream class is incompatible.
local zipFile = fileOpen( "", "rb" );

-- Check that we can access that .zip archive.
if not ( zipFile ) then
    outputDebugString( "could not open" );
    return false;

-- Try to open a content link to the .zip archive.
-- This operation will fail is the archive is not valid.
local zipTranslator = fileOpenArchive( zipFile );

if not ( zipTranslator ) then
    outputDebugString( "could not access the contents of" );
    outputDebugString( "the archive could be damaged" );
    return false;

-- This table shall contain all filenames of the archive.
local fileEntries = {};

local function fileIterator( filePath )
    -- Add the filename to our list.
    table.insert( fileEntries, zipTranslator.relPathRoot( filePath ) );

zipTranslator.scanDirEx( "/", "*", nil, fileIterator, true );

-- List the filenames on the chatbox.
for m,n in ipairs( fileEntries ) do
    outputChatBox( n );

FileSystem Namespace Functions

FileSystem Translator Functions

FileSystem Archive Translator Functions