Last active
December 17, 2015 10:49
-
-
Save webmutation/5598060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var requestFileSystem = window.webkitRequestFileSystem || window.mozRequestFileSystem || window.msRequestFileSystem || window.requestFileSystem; | |
var URL = "example.zip"; | |
var filesystem, zipFs = new zip.fs.FS(); | |
function onerror(message) { | |
console.error(message); | |
} | |
function removeRecursively(entry, onend, onerror) { | |
var rootReader = entry.createReader(); | |
console.log("Remove Recursive"+entry.fullPath); | |
rootReader.readEntries(function(entries) { | |
var i = 0; | |
function next() { | |
i++; | |
removeNextEntry(); | |
} | |
function removeNextEntry() { | |
var entry = entries[i]; | |
if (entry) { | |
if (entry.isDirectory) | |
removeRecursively(entry, next, onerror); | |
if (entry.isFile) | |
entry.remove(next, onerror); | |
} else | |
onend(); | |
} | |
removeNextEntry(); | |
}, onerror); | |
} | |
function importZipToFilesystem(callback) { | |
zipFs.importHttpContent(URL, false, onerror); | |
}, onerror); | |
} | |
function logFile(file) { | |
var reader = new FileReader(); | |
reader.onload = function(event) { | |
console.log(event.target.result); | |
console.log("--------------"); | |
}; | |
reader.onerror = onerror; | |
reader.readAsText(file); | |
} | |
function test() { | |
importZipToFilesystem(function(){ | |
console.log("Importing Zip - Complete!"); | |
}); | |
} | |
zip.workerScriptsPath = "../"; | |
window.webkitStorageInfo.requestQuota(PERSISTENT, 30*1024*1024, function(grantedBytes) { | |
window.requestFileSystem(PERSISTENT, grantedBytes, function(fs) { | |
filesystem = fs; | |
removeRecursively(filesystem.root, test, test); | |
}, onerror); | |
}, function(e) { | |
console.log('Error', e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment