Unzip()
Syntax: _Unzip(zipFileName, Folder_to_unzip_prefix)
Purpose: Extracts the contents of a zip archive to a specified location.
Parameters:
zipFileName: The name of the zip file to decompress.
Folder_to_unzip_prefix: A prefix indicating where to extract the files. Must be one of the following:
"D_": system.DocumentsDirectory
"$C_": system.CachesDirectory
"$T_": system.TemporaryDirectory
Important Notes:
"$R_" limitation: Resource folder references for extraction are ignored for stability reasons.
App Folder: Avoid unzipping images directly into the app's working folder, as it could lead to corruption.
Subfolders: Currently, it doesn't extract into existing subfolders within the destination.
Zip()
Syntax: _Zip(zipFileName, Files_to_zip_comma_separated, Files_to_zip_prefix)
Purpose: Compresses a group of files into a single zip archive.
Parameters:
zipFileName: The desired name of the output zip file.
Files_to_zip_comma_separated: A comma-separated list of filenames to include in the zip, provided as a text variable.
Files_to_zip_prefix: A prefix specifying the base location of the files you want to compress. Valid options are:
"$R_": system.ResourceDirectory
"D_": system.DocumentsDirectory
"$C_": system.CachesDirectory
"$T_": system.TemporaryDirectory
Important Notes:
"$R_" Limitation: Resource folder references for the zip output are ignored.
No
Folder Prefixes in File List:
The individual filenames you provide shouldn't include the folder
prefix; that's what the Files_to_zip_prefix
is for.
Example
Lua
-- Unzipping
success = _Unzip(
"data.zip"
,
"$T_"
)
-- Extract data.zip into the temporary directory
-- Zipping
fileList =
"save1.txt,save2.txt,config.dat"
_Zip(
"backup.zip"
, fileList,
"$D_"
)
-- Compress files from the Documents directory
Cautions
File Locations: Be mindful of where you extract and compress files. The resource folder has restrictions for these operations.
Image Handling: Unzipping images directly into the app folder carries risks; consider using a temporary location instead.