MTA:Eir/FileSystem/createArchiveTranslator
Jump to navigation
Jump to 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.
Syntax
atranslator fsnamespace.createArchiveTranslator ( file fileHandle )
Arguments
- fileHandle: a MTA:Eir FileSystem file/stream class that contains the archive.
Returns
This function returns the FileSystem translator that grants access to contents of an archive.
Remarks
This function is currently unavailable in the fileSystem.dll module.
Example
Click to collapse [-]
ClientThis 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( "theArchive.zip", "rb" ); -- Check that we can access that .zip archive. if not ( zipFile ) then outputDebugString( "could not open theArchive.zip" ); return false; end -- 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 theArchive.zip" ); outputDebugString( "the archive could be damaged" ); return false; end -- 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 ) ); end zipTranslator.scanDirEx( "/", "*", nil, fileIterator, true ); -- List the filenames on the chatbox. for m,n in ipairs( fileEntries ) do outputChatBox( n ); end
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)