Skip to content

Instantly share code, notes, and snippets.

@optikalefx
Created October 20, 2014 16:57
Show Gist options
  • Save optikalefx/28122ff5c93e31d0b407 to your computer and use it in GitHub Desktop.
Save optikalefx/28122ff5c93e31d0b407 to your computer and use it in GitHub Desktop.
app.util.unzipFile = function(url, destination, progress) {
var fileName = url.replace(/^.*[\\\/]/, '');
var withoutExt = fileName.split('.').shift();
var promise = new $.Deferred();
zip.unzip(url, destination,function(done) {
if( done === 0) {
// pass the success callback a file object of the new unzipped thing
resolveLocalFileSystemURL(destination + "/" + withoutExt, function(unzippedFileEntry) {
console.log("resolving zip promise");
promise.resolve(unzippedFileEntry);
});
} else {
app.util.progress.stop();
promise.reject(err);
console.log("unzip error", done);
}
}, progress);
return promise;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment