ftpFileSize (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


This function will return the size of the file specified on the FTP server.

 

Note: this function may not be supported on some FTP servers.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Name : STRING

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

 

Returns: INT

The size of the file in bytes or the following error codes:

- 1


- Failed to get size, see ftpLastResponse.

- 2


- Invalid ID.

- 3


- Missing or invalid 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 ftpFileSize : DINT;
VAR_INPUT
  ID   : INT;
  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;
  size : DINT;
END_VAR;
 
  gsmPower(power := ON);
  gprsOpen();
 
BEGIN
 open := (ftpOpen() = 0);
IF open THEN
    id := ftpConnect(host := host, username := usr, password := pwd);
    size := ftpFileSize(id := id, name := name);
    DebugFmt(message := "Size of " + name + " is \4", v4 := size);
    ftpDisconnect(id := id);
END_IF;
ftpClose();
END;
END_PROGRAM;