The errorCallback is launched with these error types:
InvalidValuesError: If archiveFile format is not recognized
NotFoundError: If the mode is "r" and the file does not exist, or the mode is not "r" and the file cannot be created because the path of the file after excluding its file name does not exist
IOError: If the access is denied due to insufficient permissions
UnknownError: In case of any other error
Use mode depending on which operation are intended:
Mode
Description
r
Use this mode for extracting or getting information about the contents of an archive file. file must exist. If the file does not exist, onerror will be invoked (NotFoundError). When an archive file is opened in this mode, add() will not be available. (IOError will be thrown.)
w
Use this mode to create an archive file and add files to the archive file. If file does not exist, it will be created. If file exists and the overwrite option is true, the existing file will be overwritten with empty archive. If file exists and the overwrite option is false, onerror callback will be invoked (InvalidModificationError). When an archive file is opened in this mode, getEntries(), getEntryByName(), and extractAll() are not available. (IOError will be thrown.)
rw
Use this mode for archive zipping/unzipping. If file does not exist, it will be created. If file exists and the overwrite option is true, the existing file will be overwritten with an empty archive. If file exists and the overwrite option is false, the existing contents are preserved. Both adding and extracting will be available.
a
Use this mode to add new files to an archive file. If file does not exist, it will be created. If file exists, then the previous contents of the archive file are preserved and new files can be added to the archive file. In this mode, getEntries(), getEntryByName(), and extractAll() are not available. (IOError will be thrown.)
mode: File mode for the opened archive. Determines which operations are available
onsuccess: Callback method to be invoked when archive is opened successfully
onerror [optional][nullable]: Callback method to be invoked when an error occurs
options [optional][nullable]: Additional options for initializing the ArchiveFile instance
Return value:
long Task ID which can be used to cancel the operation with abort()
Exceptions:
WebAPIException
with error type TypeMismatchError, if parameter type does not match.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function successCallback(archive) {
console.log("Success, can now read from archive " + archive);
}
function errorCallback(error) {
console.log(error);
}
tizen.archive.open("downloads/some_archive.zip", "r", successCallback, errorCallback);
abort
Cancels an operation with the given identifier.
void abort(long operationIdentifier);
Since: 2.3
Parameters:
operationIdentifier: Task ID returned by an asynchronous function from this module
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
If sourceFile refers to a directory, the directory and its content will be added to ArchiveFile.
The errorCallback is launched with these error types:
NotFoundError: If the given sourceFile does not exist
IOError: If archiveFile can not be written due the lack of access permission
InvalidModificationError: If the operation results in a name conflict in the archive
i.e. two entries in the archive with the same name (including directory names).
UnknownError: In any case of any other error
Name stored for new entries is constructed from sourceFile according to the stripSourceDirectory and destination options. Names are constructed as follows:
sourceFile: File or directory to be added to archive
onsuccess [optional][nullable]: Callback method to be invoked when this operation is completed successfully
onerror [optional][nullable]: Callback method to be invoked when an error occurs
onprogress [optional][nullable]: Callback method to be invoked to notify about operation progress
It is called every time a single source file has been completely added. If the source file is big then the callback can also be called while the file is being processed.
options [optional][nullable]: Additional options used to control how the sourceFile will be compressed and stored in the archive
Return value:
long Task ID which can be used to cancel the operation with abort()
Exceptions:
WebAPIException
with error type TypeMismatchError, if parameter is of the wrong type.
with error type InvalidStateError, if ArchiveFile is not open.
with error type InvalidAccessError, if the file mode is "r".
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function errorCallback(error) {
console.log(error);
}
function successCallback() {
console.log("done");
}
function progressCallback(opId, val, name) {
console.log("opId: " + opId + " with progress val: " + val);
}
function createSuccess(archive) {
archive.add("downloads/file.txt", successCallback, errorCallback, progressCallback);
}
tizen.archive.open("downloads/new_archive.zip", "w", createSuccess);
extractAll
Extracts every file from this ArchiveFile to a given directory.
destinationDirectory: Directory where extracted files will be stored
Specified as a virtual path or a File object representing a directory.
onsuccess [optional][nullable]: Callback method to be invoked when an archive is extracted successfully
onerror [optional][nullable]: Callback method to be invoked when an error occurs
onprogress [optional][nullable]: Callback method to be invoked while the extracting is in progress
The onprogress callback is called at least once. It will be invoked for every extracted file.
overwrite [optional][nullable]: Flag indicating whether to overwrite or keep the existing files with the same name in the destinationDirectory location when extracting an archive
By default, this attribute is set to false.
Return value:
long Task ID which can be used to cancel the operation with abort()
Exceptions:
WebAPIException
with error type TypeMismatchError, if parameter is of the wrong type.
with error type InvalidStateError, if ArchiveFile is not open.
with error type InvalidAccessError, if the file mode is "w" or "a".
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function errorCallback(error) {
console.log(error);
}
function successCallback() {
console.log("done");
}
function progressCallback(opId, val, name) {
console.log("extracting operation (: " + opId + ") is in progress (" + (val * 100).toFixed(1) + "%)");
}
function openSuccess(archive) {
archive.extractAll("music", successCallback, errorCallback, progressCallback);
}
tizen.archive.open("downloads/some_archive.zip", "r", openSuccess);
getEntries
Retrieves information about the member files in ArchiveFile.
long getEntries(ArchiveFileEntryArraySuccessCallback onsuccess, optional ErrorCallback? onerror);
Since: 2.3
The errorCallback is launched with these error types:
onsuccess: Callback method to be invoked when a file matched with the given name is found
onerror [optional][nullable]: Callback method to be invoked when an error occurs
Return value:
long Task ID which can be used to cancel the operation with abort()
Exceptions:
WebAPIException
with error type TypeMismatchError, if parameter is of the wrong type.
with error type InvalidStateError, if ArchiveFile is not opened.
with error type InvalidAccessError, if the file mode is "w" or "a".
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function errorCallback(error) {
console.log(error);
}
function getEntrySuccess(entry) {
console.log("Entry: " + entry.name + " size: " + entry.size);
}
function openSuccess(archive) {
archive.getEntryByName("arch/my_file.txt", getEntrySuccess, errorCallback);
}
tizen.archive.open("downloads/some_archive.zip", "r", openSuccess);
close
Closes the ArchiveFile.
void close();
Since: 2.3
Call this method when the archive file is not used any more. Once you call this method, the archive file object will not be available and any further operation attempt results in an InvalidStateError.
Calling close() on an archive file object which is already closed does not raise any exception.
Exceptions:
WebAPIException
with error type UnknownError, if any other error occurs.
2.6. ArchiveFileEntry
The ArchiveFileEntry interface provides access to ArchiveFile member information and file data.
interface ArchiveFileEntry {
readonly attribute DOMString name;
readonly attribute unsigned long long size;
readonly attribute unsigned long long? compressedSize;
readonly attribute Date modified;
long extract(FileReference destinationDirectory,
optional SuccessCallback? onsuccess,
optional ErrorCallback? onerror,
optional ArchiveFileProgressCallback? onprogress,
optional boolean? stripName,
optional boolean? overwrite) raises(WebAPIException);
};
Original size of the member file bytes.
If the ArchiveFileEntry member is a folder, the attribute value will be the sum of sizes of all files in this directory.
Since: 2.3
readonly unsigned long long compressedSize nullabl
Amount of storage space used by the member file, which may be compressed, in ArchiveFile bytes.
If ArchiveFileEntry member is a folder, the attribute will be sum of the sizes of all files in this directory.
Until a new entry is added to the archive, the compressedSize is null
Since: 2.3
readonly unsigned long long compressedSize nullabl
Date and time stored with the member file. This is usually the modification date of the file.
Since: 2.3
destinationDirectory: Directory where extracted files will be stored
Given as a virtual path or a File object representing a directory.
onsuccess [optional][nullable]: Callback method to be invoked when an extract operation is completed
onerror [optional][nullable]: Callback method to be invoked when an error occurs
onprogress [optional][nullable]: Callback method to be invoked while the extracting is in progress
The onprogress callback is called at least once. It will be invoked for every extracted file.
stripName [optional][nullable]: Flag which determines if directory name part of ArchiveFileEntry should be removed or preserved
The default value is false. If it is true, use only base name (part after last slash) as a target path.
overwrite [optional][nullable]: Flag which determines if it possible to overwrite files when the decompressed file already exists in this destination location
The default value is false.
Return value:
long Task ID which can be used to cancel the operation with abort()
Exceptions:
WebAPIException
with error type TypeMismatchError, if parameter is of the wrong type.
with error type InvalidValuesError, if directory parameter does not represent a directory.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function errorCallback(error) {
console.log(error);
}
function extractSuccessCallback() {
console.log("done");
}
function getEntrySuccess(entry) {
entry.extract("downloads/extract", extractSuccessCallback, errorCallback);
}
function openSuccess(archive) {
archive.getEntryByName("my_file.txt", getEntrySuccess, errorCallback);
}
tizen.archive.open("downloads/some_archive.zip", "r", openSuccess, errorCallback);
2.7. ArchiveFileSuccessCallback
The ArchiveFileSuccessCallback interface provides a SuccessCallback for the ArchiveManager::open() method.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.