added renameFile for renaming remote files
This commit is contained in:
parent
f8f0ad0692
commit
d0d7dd55c3
1 changed files with 22 additions and 0 deletions
22
helma/Ftp.js
22
helma/Ftp.js
|
@ -63,6 +63,7 @@ helma.Ftp = function(server) {
|
||||||
var GET = 40;
|
var GET = 40;
|
||||||
var PUT = 41;
|
var PUT = 41;
|
||||||
var DELETE = 42;
|
var DELETE = 42;
|
||||||
|
var RENAME = 43;
|
||||||
|
|
||||||
var FTP = Packages.org.apache.commons.net.ftp.FTP;
|
var FTP = Packages.org.apache.commons.net.ftp.FTP;
|
||||||
var FtpClient = Packages.org.apache.commons.net.ftp.FTPClient;
|
var FtpClient = Packages.org.apache.commons.net.ftp.FTPClient;
|
||||||
|
@ -510,6 +511,27 @@ helma.Ftp = function(server) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames a file on the FTP server.
|
||||||
|
*
|
||||||
|
* @example var success = ftp.renameFile("messages.tmp", "messages.txt");
|
||||||
|
* @param {String} from the name of the original file
|
||||||
|
* @param {String} to the new name the original file should get
|
||||||
|
* @return Boolean true if renaming the remote file was successful, false otherwise
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
this.renameFile = function(from, to) {
|
||||||
|
try {
|
||||||
|
var result = ftpclient.rename(from, to);
|
||||||
|
debug("renameFile", from + "->" + to);
|
||||||
|
return result;
|
||||||
|
} catch(x) {
|
||||||
|
error("renameFile", x);
|
||||||
|
setStatus(RENAME);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminates the current FTP session.
|
* Terminates the current FTP session.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue