Created
July 28, 2014 11:14
-
-
Save jleyva/df05458d20b72e3c30b8 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
MM.fs.getDirectory = function(path, createIfNotFound, successCallback, errorCallBack, dirEntry) { | |
MM.fs.loadFS(function() { | |
path = path.replace('file:///', ''); | |
var baseRoot = MM.fs.fileSystemRoot; | |
if (dirEntry) { | |
baseRoot = dirEntry; | |
} | |
MM.log('Getting directory '+path+' in '+ MM.fs.entryURL(baseRoot)+' '+createIfNotFound); | |
baseRoot.getDirectory( | |
path, | |
{create: false, exclusive: false}, | |
function(newDirEntry) { | |
MM.log('Success!'); | |
successCallback(newDirEntry, true); | |
}, | |
function(error){ | |
MM.log('Error!!'); | |
if(createIfNotFound){ | |
MM.log('File '+path+' doesnt exist. Lets create it.'); | |
MM.fs.createDir(path, successCallback, dirEntry); | |
} | |
else{ | |
MM.log('File '+path+' doesnt exist.'); | |
errorCallBack(error); | |
} | |
} | |
); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment