Skip to content

TagSpaces is an offline, open source, document manager with tagging support

added dummy functions for the rename directory funtionality

Ilian2f689f28508e
diff --git a/data/cordova/cordova.api.js b/data/cordova/cordova.api.js
index d948b2d65..9c8bfd1ac 100644
--- a/data/cordova/cordova.api.js
+++ b/data/cordova/cordova.api.js
@@ -428,6 +428,40 @@ define(function (require, exports, module) {
);
};
+ var renameDirectory = function(dirPath, newDirName) {
+ var newDirPath = TSCORE.TagUtils.extractParentDirectoryPath(dirPath) + TSCORE.dirSeparator + newDirName;
+ TSCORE.showLoadingAnimation();
+
+ dirPath = normalizePath(dirPath);
+ var newDirParentPath = normalizePath(newDirPath.substring(0, newDirPath.lastIndexOf('/')));
+ // TODO check if the newFilePath exist or cause issues by renaming
+ fsRoot.getDirectory(newDirParentPath, {create: false, exclusive: false},
+ function (parentDirEntry) {
+ fsRoot.getFile(dirPath, {create: false, exclusive: false},
+ function(entry) {
+ entry.moveTo(
+ parentDirEntry,
+ newDirName,
+ function() {
+ console.log("Directory renamed to: "+newDirPath+" Old name: "+entry.fullPath);
+ TSPOSTIO.renameFile(entry.fullPath, newDirPath);
+ },
+ function() {
+ console.log("error renaming: "+dirPath);
+ }
+ );
+ },
+ function() {
+ console.log("Error getting file: "+dirPath);
+ }
+ );
+ },
+ function (error) {
+ console.log("Getting dir: "+newDirParentPath+" failed with error code: " + error.code);
+ }
+ );
+ };
+
var selectDirectory = function() {
console.log("Open select directory dialog.");
//file:///storage/emulated/0/DCIM/Camera/
@@ -493,6 +527,7 @@ define(function (require, exports, module) {
exports.createDirectory = createDirectory;
exports.renameFile = renameFile;
+ exports.renameDirectory = renameDirectory;
exports.loadTextFile = loadTextFile;
exports.saveTextFile = saveTextFile;
exports.listDirectory = listDirectory;
diff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.js
index 695975ed7..adb958c26 100644
--- a/data/mozilla/mozilla.api.js
+++ b/data/mozilla/mozilla.api.js
@@ -176,7 +176,11 @@ define(function(require, exports, module) {
}});
document.documentElement.dispatchEvent(event);
};
-
+
+ var renameDirectory = function(filePath, newFilePath) {
+ TSCORE.showAlertDialog("Rename directory functionality is not implemented in firefox yet.");
+ };
+
var saveTextFile = function(filePath,content) {
console.log("Saving file: "+filePath);
TSCORE.showLoadingAnimation();
@@ -306,6 +310,7 @@ define(function(require, exports, module) {
exports.createDirectory = createDirectory;
exports.renameFile = renameFile;
+ exports.renameDirectory = renameDirectory;
exports.loadTextFile = loadTextFile;
exports.saveTextFile = saveTextFile;
exports.listDirectory = listDirectory;