File PhoneGap,文件复制错误:代码=1,
文件复制错误,详细信息: 2012-06-12 09:21:38.557美赞臣调试[10314:fb03][INFO]父项:=/Users/laiqinyi/Library/Application Support/iPhone Simulator/4.3.2/Applications/5EFBD6D1-66EB-4DEC-8AE7-D386729744E9/Documents/dest/File PhoneGap,文件复制错误:代码=1,,file,cordova,File,Cordova,文件复制错误,详细信息: 2012-06-12 09:21:38.557美赞臣调试[10314:fb03][INFO]父项:=/Users/laiqinyi/Library/Application Support/iPhone Simulator/4.3.2/Applications/5EFBD6D1-66EB-4DEC-8AE7-D386729744E9/Documents/dest/ 2012-06-12 09:22:34.640美赞臣调试[10314:fb03][INFO]上传错误源未定义
2012-06-12 09:22:34.640美赞臣调试[10314:fb03][INFO]上传错误源未定义
2012-06-12 09:22:34.641美赞臣调试[10314:fb03][INFO]上传错误目标未定义
我遵循API指令,不认为这个“copyTo”代码有什么问题。
此外,还有文件夹“Documents/dest”和文件“Documents/readme.txt”
嘿,我在
fileSys.root.getDirectory
调用中收到错误{code:5}
。有什么想法吗?嘿,我在fileSys.root.getDirectory
调用中收到错误{code:5}
。有什么想法吗?
**var FileSystem = {
copy : function(src, dest){
var parentEntry = new DirectoryEntry({fullPath:("/dest")});
console.log("parent_entry := " + FileSystem.root_path+"/dest");
function gotFS(fileSystem) {
fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.copyTo(parentEntry, "file.copy", function(e){console.log("copy okay");}, fail);
}
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
}**
copy : function(fromUrl, toPath, toName){
console.log("copyFile - From: [" + fromUrl + "] To: " + toPath + " Name: " + toName);
// Set up some storage
var destPath = '';
var destName = '';
doMoveFile(fromUrl);
// Called when file needs to be moved / after capture
function doMoveFile(fileUrl){
//console.log("doMoveFile - fileUrl: " + JSON.stringify(fileUrl));
// Remember the source file name just in case it was not passed so reuse it, and for logging
var destName = fileUrl.name;
var destPath = fileUrl;
// Resolve the file system
window.resolveLocalFileSystemURI(fileUrl,resFSSuccess, resFSError);
// Called upon successful File System resolution
function resFSSuccess(entry){
//console.log("resFSSuccess Success - entry: " + JSON.stringify(entry));
// Request a file system
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
requestFileSystemSuccess, requestFileSystemError);
// Called upon successful File System request
function requestFileSystemSuccess(fileSys){
// Get the source directory
fileSys.root.getDirectory(toPath, {create: true, exclusive:false}, getDestDirSuccess, getDestDirError);
// Called upon successful Get Of Destination Directory
function getDestDirSuccess(directory){
// Get the destination file name, set it if it is blank or not passed by the App
toName = (toName) ? toName : destName;
// Remember the full path name for the console log
fullDestPath = directory.fullPath + '/' + toName;
// Make the move
entry.copyTo(directory, toName, moveSuccess, moveError);
function moveSuccess(){
console.log("Successful copy of " + destPath + " to " + fullDestPath);
};
function moveError(error){
console.log("copyError code: " + JSON.stringify(error));
};
}
// Get Destination Dir Failure
function getDestDirError(error){
console.log("getDestDirError code: " + JSON.stringify(error));
};
}
// File System Request Failure
function requestFileSystemError(error){
console.log("requestFileSystemError code: " + JSON.stringify(error));
};
}
// Note File System failure
function resFSError(error){
console.log("resFSError code: " + JSON.stringify(error));
};
}
}