forked from MobileChromeApps/cordova-plugin-zip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zip.js
27 lines (25 loc) · 729 Bytes
/
zip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var exec = cordova.require('cordova/exec');
function newProgressEvent(result) {
var event = {
loaded: result.loaded,
total: result.total
};
return event;
}
exports.unzip = function(fileName, outputDirectory, callback, progressCallback) {
var win = function(result) {
if (result && typeof result.loaded != "undefined") {
if (progressCallback) {
return progressCallback(newProgressEvent(result));
}
} else if (callback) {
callback(0);
}
};
var fail = function(result) {
if (callback) {
callback(-1);
}
};
exec(win, fail, 'Zip', 'unzip', [fileName, outputDirectory]);
};