Archive
Tizen enables you to operate on the zip archive files.
The Archive API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. The Archive API is supported on all Tizen Emulators.
To use the Archive API, your application must have the following privileges:
The main features of the Archive API include:
- Accessing archive content
You can read the content of an archive file using the ArchiveFile interface (in mobile and wearable applications).
- Creating new archives
You can create archive files and add files into them using the ArchiveFile interface.
- Extracting archived files
You can extract a single file or all files from an archive file using the ArchiveFile interface.
- Aborting operations
You can abort an on-going archive operation using the operation ID and the abort() method of the ArchiveManager interface.
You can abort the operations for the open(), add(), extractAll(), getEntries(), getEntryByName(), and extract() methods.
To start any kind of zip operation (packing or unpacking), you must first call the open() method of the ArchiveManager interface (in mobile and wearable applications). The first parameter of is a FileReference object (in mobile and wearable applications), which can be a File object (in mobile and wearable applications) or the virtual path. The second parameter is a FileMode enumerator (in mobile and wearable applications), whose values are described in the following table.
Mode | Description |
---|---|
r | Use this mode to extract or get information about the archive file content.
The file must exist, or the NotFoundError exception occurs. When the archive file is opened in this mode, the add() method is not available. |
w | Use this mode to create an archive file and add files to it.
If the file does not exist, it is created. If it exists and the overwrite option is true, the existing file is overwritten with an empty archive. If the file exists and the overwrite option is false, the error callback is invoked. When the archive file is opened in this mode, the getEntries(), getEntryByName(), and extractAll() methods are not available. |
rw | Use this mode to zip or unzip an archive file.
If the file does not exist, it is created. If it exists and the overwrite option is true, the existing file is overwritten with an empty archive. If the file exists and the overwrite option is false, the existing content is preserved, and both adding and extracting are available. |
a | Use this mode to add new files to an archive file.
If the file does not exist, it is created. If it exists, the previous content of the archive file is preserved and new files can be added. When the archive file is opened in this mode, the getEntries(), getEntryByName(), and extractAll() methods are not available. |