gpt4 book ai didi

android - 我可以使用 Phonegap/cordova 框架复制目录吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:38 28 4
gpt4 key购买 nike

我想将一个目录从一个位置复制到另一个位置。我对此进行了研究,发现了 copyTo Api。在该文档中,我从文档中找到了如下快速示例

function win(entry) {
console.log("New Path: " + entry.fullPath);
}

function fail(error) {
alert(error.code);
}

function copyDir(entry) {
var parent = document.getElementById('parent').value,
newName = document.getElementById('newName').value,
parentEntry = new DirectoryEntry({fullPath: parent});

// copy the directory to a new directory and rename it
entry.copyTo(parentEntry, newName, success, fail);
}

现在我怎么混淆源路径变量和目标路径变量在哪里?任何人都可以为我提供一个很好的例子吗

最佳答案

希望以下内容能帮助您理解:

var root;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSystem) {
root = fileSystem.root;
// get the directory we want to get within the root directory
var srcDir = 'srcDir';
root.getDirectory(srcDir, {create: false}, getDirectoryWin, getDirectoryFail);
});

// the directory param should be a DirectoryEntry object that points to the srcDir
function getDirectoryWin(directory){
console.log('got the directory');

// path to the parent directory that holds the dir that we want to copy to
// we'll set it as the root, but otherwise you'll
// need parentDir be a DirectoryEntry object
var parentDir = root;

// name of the destination directory within the parentDir
var dstDir = 'dstDir';

// use copyWin/copyFail to launch callbacks when it works/fails
directory.copyTo(root, dstDir, copyWin, copyFail);
}

function getDirectoryFail(){
console.log("I failed at getting a directory");
}

function copyWin(){
console.log('Copying worked!');
}

function copyFail(){
console.log('I failed copying');
}

关于android - 我可以使用 Phonegap/cordova 框架复制目录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14451555/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com