fs.rename(filePath, newFilePath, function(error) { if (error) { console.log("Renaming file failed "+error); return; } TSPOSTIO.renameFile(filePath, newFilePath); });
fsRoot.move(filePath, newFilePath, function (err, stat) { if(err) { console.log("Error renaming: "+err); } else { console.log("File renamed to: "+stat.path); TSPOSTIO.renameFile(filePath, stat.path); } });
fs.rename(filePath, newFilePath, function(error) { if (error) { TSCORE.hideWaitingDialog(); TSCORE.showAlertDialog($.i18n.t("ns.common:fileRenameFailedDiffPartition", { fileName:filePath })); return; } TSPOSTIO.renameFile(filePath, newFilePath); });
fs.rename(filePath, newFilePath, function(error) { if (error) { TSCORE.hideWaitingDialog(); TSCORE.showAlertDialog("Renaming of '"+filePath+"' failed. The file is probably on a different partion."); return; } TSPOSTIO.renameFile(filePath, newFilePath); });
reader.onloadend = function(e) { var data = Array.prototype.slice.call(new Uint8Array(reader.result), 0); nativeIO.saveBlobToFile(newFilePath, data); if (nativeIO.fileExists(newFilePath)) { nativeIO.removeRecursively(filePath); } TSPOSTIO.renameFile(filePath, newFilePath); };
var renameFile = function(filePath, newFilePath) { console.log("Renaming file: " + filePath + " to " + newFilePath); TSCORE.showLoadingAnimation(); if (filePath.toLowerCase() == newFilePath.toLowerCase()) { console.log("Initial and target filenames are the same..."); return false; } if (nativeIO.fileExists(newFilePath)) { console.log("File renaming failed! Target filename already exists."); return false; } if (isWin) { if (nativeIO.renameFile(filePath, newFilePath)) { TSPOSTIO.renameFile(filePath, newFilePath); } else { console.error("File renaming failed!"); } } else { if (nativeIO.fileExists(filePath)) { var blob; var size = nativeIO.getFileSize(filePath); // TODO remove the 5MB restriction if (size > 5 * 1024 * 1024) { TSCORE.showAlertDialog("In Chrome, TagSpaces does not support renaming/tagging of files bigger than 5MB!"); return; } if (size) { var byteArray = nativeIO.contentsAtPath(filePath); blob = new Int8Array(byteArray); } else { blob = new Int8Array(0); } var b = new Blob([blob]); b.size = size; var reader = new FileReader(); reader.onloadend = function(e) { var data = Array.prototype.slice.call(new Uint8Array(reader.result), 0); nativeIO.saveBlobToFile(newFilePath, data); if (nativeIO.fileExists(newFilePath)) { nativeIO.removeRecursively(filePath); } TSPOSTIO.renameFile(filePath, newFilePath); }; reader.readAsArrayBuffer(b); } else { console.error("File does not exists..."); } } };
function(status, data, headers) { console.log("Rename File Status/Content/Headers: " + status + " / " + data + " / " + headers); TSPOSTIO.renameFile(filePath, newFilePath); },
var renameFile = function(filePath, newFilePath) { console.log("Renaming file: " + filePath + " to " + newFilePath); TSCORE.showLoadingAnimation(); TSPOSTIO.renameFile(filePath, newFilePath); };
TSCORE.IO.renameFilePromise(filePath, newFilePath).then(function(success) { TSCORE.hideWaitingDialog(); TSPOSTIO.renameFile(filePath, newFilePath); }, function(err) {
document.documentElement.addEventListener("tsMessage", function(event) { console.log("Message received in page script from content script: "); //+JSON.stringify(event.detail)); var message = event.detail; switch (message.command) { case "loadSettings": if(message.success) { try { console.log("Loading settings...: "+JSON.stringify(message.content)); TSCORE.Config.updateSettingMozillaPreferences(message.content); TSCORE.initLocations(); TSCORE.generateTagGroups(); } catch (ex) { console.log("Exception while getting setting from firefox failed "+ex); } } else { console.log("Getting setting from firefox failed"); } break; case "saveSettings": if(message.success) { console.log("Saving setting as native mozilla preference successfull!"); } else { console.log("Saving setting as native mozilla preference failed!"); } break; case "rename": if(message.success){ TSPOSTIO.renameFile(message.content[0],message.content[1]); } else { TSCORE.updateLogger("Rename failed"); } break; case "saveTextFile": if(message.success){ TSPOSTIO.saveTextFile(message.content); } else { TSCORE.updateLogger("Save failed"); } break; case "createDirectory": if(message.success){ TSPOSTIO.createDirectory(message.content); } else { TSCORE.updateLogger("Create dir failed"); } break; case "loadTextFile": if(message.success){ TSPOSTIO.loadTextFile(message.content); } else { TSCORE.updateLogger("File loading failed"); } break; case "listDirectory": if(message.success){ TSPOSTIO.listDirectory(message.content); } else { TSPOSTIO.errorOpeningPath(); } break; case "indexDirectory": if(message.success){ TSPOSTIO.createDirectoryIndex(message.content); } else { TSCORE.updateLogger("Indexing directory failed"); } break; case "createDirectoryTree": if(message.success){ console.log("Directory tree: "+JSON.stringify(message.content)); TSPOSTIO.createDirectoryTree(message.content); } else { TSCORE.updateLogger("Indexing directory failed"); } break; case "delete": if(message.success){ TSPOSTIO.deleteElement(message.content); } else { TSCORE.updateLogger("Delete failed"); } break; case "selectDirectory": if(message.success){ TSPOSTIO.selectDirectory(message.content); } else { TSCORE.updateLogger("Selecting directory failed."); } break; case "checkNewVersion": if(message.success){ TSPOSTIO.checkNewVersion(message.content); } else { TSCORE.updateLogger("Checking for new version failed."); } case "getFileProperties": if(message.success){ TSPOSTIO.getFileProperties(message.content); } else { TSCORE.updateLogger("Getting file properties failed."); } break; default: break; } }, false);
function() { console.log("File renamed to: "+newFilePath+" Old name: "+entry.fullPath); TSPOSTIO.renameFile(entry.fullPath, newFilePath); },
document.documentElement.addEventListener("tsMessage", function(event) { console.log("Message received in page script from content script: "); //+JSON.stringify(event.detail)); TSCORE.hideLoadingAnimation(); var message = event.detail; switch (message.command) { case "loadSettings": if(message.success) { try { console.log("Loading settings...: "+JSON.stringify(message.content)); TSCORE.Config.updateSettingMozillaPreferences(message.content); TSCORE.initConnections(); TSCORE.generateTagGroups(); } catch (ex) { console.log("Exception while getting setting from firefox failed "+ex); } } else { console.log("Getting setting from firefox failed"); } break; case "saveSettings": if(message.success) { console.log("Saving setting as native mozilla preference successfull!"); } else { console.log("Saving setting as native mozilla preference failed!"); } break; case "rename": if(message.success){ TSPOSTIO.renameFile(message.content[0],message.content[1]); } else { TSCORE.updateLogger("Rename failed"); } break; case "saveTextFile": if(message.success){ TSPOSTIO.saveTextFile(message.content); } else { TSCORE.updateLogger("Save failed"); } break; case "createDirectory": if(message.success){ TSPOSTIO.createDirectory(); } else { TSCORE.updateLogger("Create dir failed"); } break; case "loadTextFile": if(message.success){ TSPOSTIO.loadTextFile(message.content); } else { TSCORE.updateLogger("File loading failed"); } break; case "listDirectory": if(message.success){ TSPOSTIO.listDirectory(message.content); } else { TSCORE.updateLogger("List directory failed"); } break; case "indexDirectory": if(message.success){ TSPOSTIO.createDirectoryIndex(message.content); } else { TSCORE.updateLogger("Indexing directory failed"); } break; case "createDirectoryTree": if(message.success){ console.log("Directory tree: "+JSON.stringify(message.content)); TSPOSTIO.createDirectoryTree(message.content); } else { TSCORE.updateLogger("Indexing directory failed"); } break; case "getSubdirs": if(message.success){ var dirListing = []; for (var i=0; i < message.content.length; i++) { dirListing.push(message.content[i]); } // TODO JSON functions are a workarround for a bug.... TSPOSTIO.getSubdirs(JSON.parse( JSON.stringify(dirListing))); } else { TSCORE.updateLogger("Getting subdirs failed"); } break; case "delete": if(message.success){ TSPOSTIO.deleteElement(); } else { TSCORE.updateLogger("Delete failed"); } break; case "selectDirectory": if(message.success){ TSPOSTIO.selectDirectory(message.content); } else { TSCORE.updateLogger("Selecting directory failed."); } break; case "checkNewVersion": if(message.success){ TSPOSTIO.checkNewVersion(message.content); } else { TSCORE.updateLogger("Create dir failed"); } break; default: break; } }, false);