DosFindNext

Finds the next set of file objects whose names match the specification in a previous call to DosFindFirst or DosFindNext.

Syntax
DosFindNext(hDir, pfindbuf, cbfindbuf, pcFilenames)

Parameters

 * hDir (HDIR) - input: The handle of the directory.
 * pfindbuf (PVOID) - in/out: The address of the directory search information structure.
 * The information returned reflects the most recent call to DosClose or DosResetBuffer.
 * For the continuation of a Level 3 (FIL_QUERYEASFROMLIST) File Informationsearch, this buffer should contain input in the same format as a Level 3 File Information search by DosFindFirst.
 * See the description of the pfindbuf parameter in DosFindFirst for information about the output data that the file system driver places into this buffer.


 * cbfindbuf (ULONG) - input: The length, in bytes, of pfindbuf.
 * pcFilenames (PULONG) - in/out : Pointer to the number of entries.
 * Input
 * The address of the number of matching entries requested in pfindbuf.
 * Output
 * The number of entries placed into pfindbuf.

Return Code

 * ulrc (APIRET) - returns:DosFindNext returns one of the following values:
 * 0  NO_ERROR
 * 6  ERROR_INVALID_HANDLE
 * 18 ERROR_NO_MORE_FILES
 * 26 ERROR_NOT_DOS_DISK
 * 87 ERROR_INVALID_PARAMETER
 * 111 ERROR_BUFFER_OVERFLOW
 * 275 ERROR_EAS_DIDNT_FIT

Remarks
If ERROR_BUFFER_OVERFLOW is returned, further calls to DosFindNext start the search from the same entry.

If ERROR_EAS_DIDNT_FIT is returned, the buffer is too small to hold the extended attributes (EAs) for the first matching entry being returned. A subsequent call to DosFindNext gets the next matching entry. This enables the search to continue if the extended attributes being returned are too large for the buffer. You can use DosQueryPathInfo to retrieve the extended attributes for the matching entry by using the same EA arguments used for the call to DosFindFirst, and the name that was returned by DosFindFirst,

In the case of ERROR_EAS_DIDNT_FIT, only information for the first matching entry is returned. This is the entry whose extended attributes did not fit in the buffer. The information returned is in the format of Level 2 (FIL_QUERYEASIZE) File Information (FILEFINDBUF4). No further entries are returned in the buffer, even if they could fit in the remaining space.

Example Code
This example lists all the normal files that are in the directory from where the example is invoked. 
 * 1) define INCL_DOSFILEMGR  /* File Manager values */
 * 2) define INCL_DOSERRORS   /* DOS error values */
 * 3) include 
 * 4) include 

int main (VOID) { HDIR         hdirFindHandle = HDIR_CREATE; FILEFINDBUF3 FindBuffer     = {0};      /* Returned from FindFirst/Next */ ULONG        ulResultBufLen = sizeof(FILEFINDBUF3); ULONG        ulFindCount    = 1;        /* Look for 1 file at a time    */ APIRET       rc             = NO_ERROR; /* Return code                  */

rc = DosFindFirst( "*.*",               /* File pattern - all files     */                       &hdirFindHandle,      /* Directory search handle      */                       FILE_NORMAL,          /* Search attribute             */                       &FindBuffer,          /* Result buffer                */                       ulResultBufLen,       /* Result buffer length         */                       &ulFindCount,         /* Number of entries to find    */                       FIL_STANDARD);        /* Return level 1 file info     */

if (rc != NO_ERROR) { printf("DosFindFirst error: return code = %u\n",rc); return 1; } else { printf ("%s\n", FindBuffer.achName);  /* Print file name             */ } /* endif */

/* Keep finding the next file until there are no more files */ while (rc != ERROR_NO_MORE_FILES) { ulFindCount = 1;                     /* Reset find count. */

rc = DosFindNext(hdirFindHandle,     /* Directory handle             */                        &FindBuffer,         /* Result buffer                */                        ulResultBufLen,      /* Result buffer length         */                        &ulFindCount);       /* Number of entries to find    */

if (rc != NO_ERROR && rc != ERROR_NO_MORE_FILES) { printf("DosFindNext error: return code = %u\n",rc); return 1; } else { printf ("%s\n", FindBuffer.achName);   /* Print file name */ }   } /* endwhile */

rc = DosFindClose(hdirFindHandle);   /* Close our directory handle */ if (rc != NO_ERROR) { printf("DosFindClose error: return code = %u\n",rc); return 1; }   return NO_ERROR; } 

Related Functions

 * DosClose
 * DosFindClose
 * DosFindFirst
 * DosQueryFileInfo
 * DosQueryPathInfo
 * DosQuerySysInfo
 * DosResetBuffer
 * DosSearchPath
 * DosSetFileInfo
 * DosSetPathInfo