in src/windows/FileProxy.js [722:786]
getDirectory: function (win, fail, args) {
const dirurl = args[0];
const path = args[1];
const options = args[2];
const fs = getFilesystemFromURL(dirurl);
const dirpath = pathFromURL(dirurl);
if (!fs || !validName(path)) {
fail(FileError.ENCODING_ERR);
return;
}
const fspath = sanitize(dirpath + '/' + path);
const completePath = sanitize(fs.winpath + fspath);
const name = completePath.substring(completePath.lastIndexOf('/') + 1);
const wpath = cordovaPathToNative(completePath.substring(0, completePath.lastIndexOf('/')));
let flag = '';
if (options) {
flag = new Flags(options.create, options.exclusive);
} else {
flag = new Flags(false, false);
}
getFolderFromPathAsync(wpath).done(
function (storageFolder) {
if (flag.create === true && flag.exclusive === true) {
storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.failIfExists).done(
function (storageFolder) {
win(new DirectoryEntry(storageFolder.name, fspath, fs.name, fs.makeNativeURL(fspath)));
}, function (err) { // eslint-disable-line n/handle-callback-err
fail(FileError.PATH_EXISTS_ERR);
}
);
} else if (flag.create === true && flag.exclusive === false) {
storageFolder.createFolderAsync(name, Windows.Storage.CreationCollisionOption.openIfExists).done(
function (storageFolder) {
win(new DirectoryEntry(storageFolder.name, fspath, fs.name, fs.makeNativeURL(fspath)));
}, function () {
fail(FileError.INVALID_MODIFICATION_ERR);
}
);
} else if (flag.create === false) {
storageFolder.getFolderAsync(name).done(
function (storageFolder) {
win(new DirectoryEntry(storageFolder.name, fspath, fs.name, fs.makeNativeURL(fspath)));
},
function () {
// check if path actually points to a file
storageFolder.getFileAsync(name).done(
function () {
fail(FileError.TYPE_MISMATCH_ERR);
}, function () {
fail(FileError.NOT_FOUND_ERR);
}
);
}
);
}
}, function () {
fail(FileError.NOT_FOUND_ERR);
}
);
},