ftpFileRename (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


This function renames a file on the FTP server.

 

 

Note:

If no path information is included in the new name, the file remains at the same location. Otherwise the file will be moved to the new location with the new name which may be the same as the old.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Old_Name : STRING

Name of the file to rename. Both absolute and relative paths are allowed.

 

New_Name : STRING

The new location and name of the file.

 

Returns: INT

0


- Success.

- 1


- Rename failed, see ftpLastResponse.

- 2


- Invalid ID.

- 3


- Invalid old or new name.

- 4


- Session is busy with another operation.

- 5


- FTP not open, use ftpOpen to open interface.

- 10


- Communication with server not possible.

 

Declaration:

FUNCTION ftpFileRename : INT;
VAR_INPUT
  ID       : INT;
  Old_Name : STRING;
  New_Name : STRING;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  open : BOOL;
  host : STRING := "ftp.domain.com";
  usr   : STRING := "ftpuser";
  pwd   : STRING := "user pwd";
 
  name   : STRING := "test.txt";
 
  id   : INT;
END_VAR;
 
  gsmPower(power := ON);
  gprsOpen();
 
BEGIN
 open := (ftpOpen() = 0);
IF open THEN
    id := ftpConnect(host := host, username := usr, password := pwd);
    ftpFileRename(id := id, old_name := name, new_name := "o_" + name);
    ftpDisconnect(id := id);
END_IF;
ftpClose();
END;
END_PROGRAM;