-
-
Save engincancan/7114629 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
<title></title> | |
<script type="text/javascript" charset="utf-8" src="lib/android/cordova-1.7.0.js"></script> | |
<script type="text/javascript"> | |
(function(){ | |
document.addEventListener("deviceready", onDeviceReady, false); | |
function onDeviceReady() { | |
console.log("device is ready"); | |
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) { | |
window.FS = fileSystem; | |
var printDirPath = function(entry){ | |
console.log("Dir path - " + entry.fullPath); | |
} createDirectory(folder,localFileName,remoteFile, printDirPath); | |
}, fail); | |
} | |
function fail() { | |
console.log("failed to get filesystem"); | |
} | |
function createDirectory(path, success){ | |
var dirs = path.split("/").reverse(); | |
var root = window.FS.root; | |
var createDir = function(dir){ | |
console.log("create dir " + dir); | |
root.getDirectory(dir, { | |
create : true, | |
exclusive : false | |
}, successCB, failCB); | |
}; | |
var successCB = function(entry){ | |
console.log("dir created " + entry.fullPath); | |
root = entry; | |
if(dirs.length > 0){ | |
createDir(dirs.pop()); | |
}else{ | |
console.log("all dir created"); | |
success(entry); | |
} | |
}; | |
var failCB = function(){ | |
console.log("failed to create dir " + dir); | |
}; | |
createDir(dirs.pop()); | |
} | |
})(); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment