Purpose
DosFindNext finds the next set of file objects whose names match the specification in a previous call to DosFindFirst or DosFindNext.
Syntax
#define INCL DOSFILEMGR #include os2.h
APIRET DosFindNext
Parameters
hDir HDIR) input
The information returned reflects the most recent call to DosClose or DosResetBuffer.
For the continuation of a Level 3 (FIL_QUERYEASFROMLIST) File Information search, 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.
Input
Returns
ulrc APIRET) returns
DosFindNext returns one of the following values
18
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 or Level 12 (FIL_QUERYEASIZE) File Information (FILEFINDBUF4 or FILEFINDBUF4L). No further entries are returned in the buffer, even if they could fit in the remaining space.
Related Functions
Example Code
This example lists all the normal files that are in the directory from where the example is invoked.
#define INCL_DOSFILEMGR /* File Manager values */#define INCL_DOSERRORS /* DOS error values */ #include os2.h #include stdio.h int main (VOID) HDIR hdirFindHandle = HDIR_CREATE; FILEFINDBUF3L FindBuffer = 0 ; /* Returned from FindFirst/Next */ ULONG ulResultBufLen = sizeof(FILEFINDBUF3L); 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_STANDARDL); /* 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;