in src/windows/FileProxy.js [407:481]
function transport (success, fail, args, ops) { // ["fullPath","parent", "newName"]
const src = args[0];
const parent = args[1];
const name = args[2];
const srcFS = getFilesystemFromURL(src);
const dstFS = getFilesystemFromURL(parent);
const srcPath = pathFromURL(src);
const dstPath = pathFromURL(parent);
if (!(srcFS && dstFS && validName(name))) {
fail(FileError.ENCODING_ERR);
return;
}
const srcWinPath = cordovaPathToNative(sanitize(srcFS.winpath + srcPath));
const dstWinPath = cordovaPathToNative(sanitize(dstFS.winpath + dstPath));
const tgtFsPath = sanitize(dstPath + '/' + name);
const tgtWinPath = cordovaPathToNative(sanitize(dstFS.winpath + dstPath + '/' + name));
if (srcWinPath === dstWinPath || srcWinPath === tgtWinPath) {
fail(FileError.INVALID_MODIFICATION_ERR);
return;
}
WinJS.Promise.join({
src: openPath(srcWinPath),
dst: openPath(dstWinPath),
tgt: openPath(tgtWinPath, { getContent: true })
}).done(
function (the) {
if ((!the.dst.folder) || !(the.src.folder || the.src.file)) {
fail(FileError.NOT_FOUND_ERR);
return;
}
if ((the.src.folder && the.tgt.file) ||
(the.src.file && the.tgt.folder) ||
(the.tgt.folder && (the.tgt.files.length || the.tgt.folders.length))) {
fail(FileError.INVALID_MODIFICATION_ERR);
return;
}
if (the.src.file) {
ops.fileOp(the.src.file, the.dst.folder, name, Windows.Storage.NameCollisionOption.replaceExisting)
.done(
function (storageFile) {
success(new FileEntry(
name,
tgtFsPath,
dstFS.name,
dstFS.makeNativeURL(tgtFsPath)
));
},
function () {
fail(FileError.INVALID_MODIFICATION_ERR);
}
);
} else {
ops.folderOp(the.src.folder, the.dst.folder, name).done(
function () {
success(new DirectoryEntry(
name,
tgtFsPath,
dstFS.name,
dstFS.makeNativeURL(tgtFsPath)
));
},
function () {
fail(FileError.INVALID_MODIFICATION_ERR);
}
);
}
},
function () {
fail(FileError.INVALID_MODIFICATION_ERR);
}
);
}