ftpDirCatalog (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


This function will return an entry from the catalog fetched with ftpDirCatalogGet.

Names in the list are not sorted and are listed in the order received from the server.

 

Note:

The size of a directory is always 0.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Index : INT (1..64)

Index to be returned in the range of 1 to the value returned by ftpDirCatalogGet.

 

Output:

Name : STRING

File name.

 

Size : DINT

File size.

 

Returns: INT

2


- Index is a directory.

1


- Index is a file.




- 1


- Catalog has not been fetched, see ftpDirCatalogGet.

- 2


- Invalid ID.

- 3


- Invalid index.

- 4


- Session is busy with another operation.

- 5


- FTP not open, use ftpOpen to open interface.

- 10


- Communication with server not possible

 

Declaration:

FUNCTION ftpDirCatalog : INT;
VAR_INPUT
  ID     : INT;
  Index : INT;
  Name   : ACCESS STRING;
  Size   : ACCESS DINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  open : BOOL;
  host : STRING := "ftp.domain.com";
  usr   : STRING := "ftpuser";
  pwd   : STRING := "user pwd";
 
  id   : INT;
 
  count : INT;
  rc, i : INT;
  name : STRING;
  size : DINT;
END_VAR;
 
  gsmPower(power := ON);
  gprsOpen();
 
BEGIN
 open := (ftpOpen() = 0);
IF open THEN
    id := ftpConnect(host := host, username := usr, password := pwd);
    count := ftpDirCatalogGet(id := id);
   
    FOR i := 1 TO count DO
      rc := ftpDirCatalog(id := id, index := i, name := name, size := size);
      CASE rc OF
        1 : DebugFmt(message := "File name = '" + name +"' size = \4", v4 := size);
        2 : DebugFmt(message := "Dir  name = '" + name +"' size = \4", v4 := size);
      END_CASE;
    END_FOR;
 
    ftpDisconnect(id := id);
END_IF;
ftpClose();
END;
END_PROGRAM;