in src/browser/FileProxy.js [428:462]
exports.getParent = function (successCallback, errorCallback, args) {
if (typeof successCallback !== 'function') {
throw Error('Expected successCallback argument.');
}
let fullPath = args[0];
// fullPath is like this:
// file:///persistent/path/to/file or
// file:///persistent/path/to/directory/
if (fullPath === DIR_SEPARATOR || fullPath === pathsPrefix.cacheDirectory ||
fullPath === pathsPrefix.dataDirectory) {
successCallback(fs_.root);
return;
}
// To delete all slashes at the end
while (fullPath[fullPath.length - 1] === '/') {
fullPath = fullPath.substr(0, fullPath.length - 1);
}
const pathArr = fullPath.split(DIR_SEPARATOR);
pathArr.pop();
const parentName = pathArr.pop();
const path = pathArr.join(DIR_SEPARATOR) + DIR_SEPARATOR;
// To get parent of root files
const joined = path + parentName + DIR_SEPARATOR;// is like this: file:///persistent/
if (joined === pathsPrefix.cacheDirectory || joined === pathsPrefix.dataDirectory) {
exports.getDirectory(successCallback, errorCallback, [joined, DIR_SEPARATOR, { create: false }]);
return;
}
exports.getDirectory(successCallback, errorCallback, [path, parentName, { create: false }]);
};