L_InetFtpBrowseDir

#include "ltweb.h"

L_INT EXT_FUNCTION L_InetFtpBrowseDir(hFtp, pszSearch, pfnCallback, pData)

HFTP hFtp;

/* handle to an FTP connection */

L_TCHAR L_FAR *pszSearch;

/* directory path or file name */

FTPBROWSECALLBACK pfnCallback;

/* pointer to a callback function */

L_VOID L_FAR *pData;

/* pointer to additional parameters */

Browses a specific directory or searches for a specific file on an FTP server's file system.

Parameter

Description

hFtp

Valid HFTP handle to an FTP connection.

pszSearch

Character string that contains a valid directory path or file name for the FTP server's file system. The string can contain wildcards, but no blank spaces are allowed. If the value of pszSearch is NULL or if it is an empty string, it will find the first file in the current directory on the server. This is a NULL-terminated string.

pfnCallback

Optional callback function that will receive the data found during the browse/search.

 

image\sqrblit.gif If you do not provide a callback function, use NULL as the value of this parameter.

 

image\sqrblit.gif If you do provide a callback function, use the function pointer as the value of this parameter.

 

The callback function must adhere to the function prototype described in the FTPBROWSECALLBACK Function.

pData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID L_FAR *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Searches the specified directory of the given FTP connection. File and directory entries are returned to the application in the FILEDATA structure of the callback function.

Required DLLs and Libraries

LTFIL
LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

FTPBROWSECALLBACK, L_InetFtpCreateDir, L_InetFtpChangeDir

Topics:

FTP Functions: Directory Manipulation Over an FTP Connection

 

How to Program with FTP Functions

Example

//This example connects to an ftp server and browses a directory. If found it adds files to a list.

void AddFileToList(L_TCHAR L_FAR * pszFileName, L_UINT32 uSize)
{
   // Process file data here
}

L_INT CALLBACK BrowseDirCallBack(L_TCHAR L_FAR * pszFile, pFILEDATA pFileData, L_VOID L_FAR * pUserData)
{
   AddFileToList(pszFile, pFileData->uFileSize);
   return SUCCESS;
}

L_INT CFtpTestView::BrowseFtpDir(L_TCHAR L_FAR *pszDirName, L_TCHAR L_FAR *pszServerName, L_TCHAR L_FAR *pszUserName, L_TCHAR L_FAR *pszPassword)
{
   HFTP hFtp;
   L_INT nRetCode = SUCCESS;
   L_INT iPort = 21; //Deafult ftp port
   nRetCode = L_InetFtpConnect (pszServerName, iPort, pszUserName, pszPassword, &hFtp);
   if(nRetCode==SUCCESS)
      L_InetFtpBrowseDir
(hFtp, pszDirName , BrowseDirCallBack, NULL);
   L_InetFtpDisConnect(hFtp);
}