我有一个const std :: string,我要追加另一个字符串。但由于它是不变的,我不能直接改变它;我不得不以某种方式将它复制到另一个字符串。我该怎么做?
答案 0 :(得分:4)
您只需创建另一个字符串:
function crea(){
alert(cordova.file.externalDataDirectory);
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
alert("got main dir",dir);
dir.getFile("log1.txt", {create:true}, function(file) {
alert("got the file", file);
});
});
}
function del(){
var relativeFilePath = cordova.file.dataDirectory;
var filename = "log1.txt";
alert(relativeFilePath);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
// alert(fileSystem.root.fullPath);
fileSystem.root.getFile(relativeFilePath + filename, {create:false}, function(fileEntry){
fileEntry.remove(function(file){
alert("File removed!");
},function(){
alert("error deleting the file " + error.code);
});
},function(){
alert("file does not exist");
});
},function(evt){
alert(evt.target.error.code);
});
}