CHttpQueue::EnumFiles Method  
 
LONG EnumFiles(
  LPCTSTR lpszFileMask,  
  DWORD dwQueueMode,  
  DWORD dwExcludeFiles,  
  LPDWORD lpFileList,  
  LONG nMaxFiles  
);

The EnumFiles method returns a list of files in the current transfer queue.

Parameters

lpszFileMask
A null-terminated string which specifies a file name which can include wildcards. Only those files which match this value will be enumerated. The character '?' will match against any single character, and '*' will match any number of characters. If this parameter is NULL or points to an empty string, all eligible files in the queue will be matched.
dwQueueMode
An unsigned integer value which specifies if the file name should be matched against downloaded files, uploaded files or all files in the queue. Only those files which match the queue mode will be enumerated. This is a bitmask which may be one or more of the following values:
Constant Description
HTTP_QUEUE_ALL Match the file name to all files in the queue.
HTTP_QUEUE_DOWNLOAD Match file names which are queued for download.
HTTP_QUEUE_UPLOAD Match file names which are queued for upload.
HTTP_QUEUE_LOCAL Match against the local file name instead of the remote file name.
dwExcludeFiles
An unsigned integer value which specifies which files to exclude from the enumeration. If this value is zero, no files will be excluded; otherwise, this value is constructed by using a bitwise operator with any of the following values:
Value Description
HTTP_QUEUE_FLAG_NONE No files should be excluded.
HTTP_QUEUE_FLAG_COMPLETED Exclude files which have been transferred. This flag is set after a queued file has been uploaded or downloaded successfully.
HTTP_QUEUE_FLAG_FAILED Exclude files which where not successfully uploaded or downloaded. This flag is set when an error occurs, either when establishing a connection with the server or during the file transfer.
HTTP_QUEUE_FLAG_CANCELED Exclude files which were canceled during the file transfer. This flag is only set when the Cancel method has been called and a queued file is in the process of being uploaded or downloaded.
lpFileList
A pointer to an array of unsigned integer values which will contain the unique file identifiers for each matching file in the queue. This parameter must specify an array large enough to store all of the file identifiers, otherwise the method will fail with a ST_ERROR_BUFFER_TOO_SMALL error. If this parameter is NULL, the method will return the number of matching files.
nMaxFiles
An integer value which specifies the maximum number of file identifiers which can be copied into the lpFileList array. If the lpFileList parameter is not NULL, this value must be greater than zero.

Return Value

If the method succeeds, the return value is the number of matching files. If the queue is empty or there are no matching files, this method will return zero. If the method fails, the return value is HTTP_ERROR. To get extended error information, call GetLastError.

Remarks

This method populates an array of unique file identifiers which can be used to obtain information about the files in the current queue. The values returned in the lpFileList array can be used in conjunction with the GetFile method. This provides an alternative to using the GetFirstFile and GetNextFile methods.

The application should not make any assumptions about the value of the file identifiers returned by this method. They should be considered opaque values which are only guaranteed to uniquely identify a file in the transfer queue. In particular, there is no guarantee that the file identifiers will be sequential and they should not be used as index values into an array.

Example

// Get the total number of files in the queue
LONG nFiles = pQueue->GetCount();

// Display information about the queued files
if (nFiles > 0)
{
    DWORD *pdwFileList = new DWORD[nFiles];
    nFiles = pQueue->EnumFiles(NULL, HTTP_QUEUE_ALL, HTTP_QUEUE_FLAG_NONE, pdwFileList, nFiles);

    for (LONG nIndex = 0; nIndex < nFiles; nIndex++)
    {
        HTTPQUEUEDFILE queuedFile;

        if (pQueue->GetFile(pdwFileList[nIndex], &queuedFile) == FALSE)
            break;
            
        switch (queuedFile.dwMode)
        {
        case HTTP_QUEUE_DOWNLOAD:
               _tprintf(_T("%u: Download \"%s\" to \"%s\"\n"),
                        queuedFile.dwFileId,
                        queuedFile.szRemoteFile,
                        queuedFile.szLocalFile);
                break;

        case HTTP_QUEUE_UPLOAD:
               _tprintf(_T("%u: Upload \"%s\" to \"%s\"\n"),
                        queuedFile.dwFileId,
                        queuedFile.szLocalFile,
                        queuedFile.szRemoteFile);
                break;
        }
    }
    
    delete pdwFileList;
}

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also