Jump to content

DosFindNext: Difference between revisions

From EDM2
Ak120 (talk | contribs)
m Ak120 moved page OS2 API:CPI:DosFindNext to DosFindNext
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
==Description==
==Description==
Finds the next set of file objects whose names match the specification in a previous call to DosFindFirst or DosFindNext.
Finds the next set of file objects whose names match the specification in a previous call to DosFindFirst or DosFindNext.


==Syntax==
==Syntax==
Line 15: Line 14:


ulrc = DosFindNext(hDir, pfindbuf, cbfindbuf, pcFilenames);
ulrc = DosFindNext(hDir, pfindbuf, cbfindbuf, pcFilenames);
</PRE>


</PRE>
==Parameters==
==Parameters==
; hDir (HDIR) - input : The handle of the directory.  
;hDir (HDIR) - input : The handle of the directory.  
 
;pfindbuf (PVOID) - in/out : The address of the directory search information structure.
; pfindbuf (PVOID) - in/out : The address of the directory search information structure.


The information returned reflects the most recent call to DosClose or DosResetBuffer.
The information returned reflects the most recent call to DosClose or DosResetBuffer.
Line 28: Line 26:
See the description of the pfindbuf parameter in DosFindFirst for information about the output data that the file system driver places into this buffer.  
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.  
;cbfindbuf (ULONG) - input : The length, in bytes, of pfindbuf.
 
;pcFilenames (PULONG) - in/out : Pointer to the number of entries.
; pcFilenames (PULONG) - in/out : Pointer to the number of entries.
:Input
 
::The address of the number of matching entries requested in pfindbuf.
Input
:Output
        The address of the number of matching entries requested in pfindbuf.  
::The number of entries placed into pfindbuf.
Output
        The number of entries placed into pfindbuf.


==Return Code==
==Return Code==
Line 42: Line 37:


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


==Remarks==
==Remarks==
Line 60: Line 54:
==Example Code==
==Example Code==
This example lists all the normal files that are in the directory from where the example is invoked.
This example lists all the normal files that are in the directory from where the example is invoked.
<PRE>
<PRE>
  #define INCL_DOSFILEMGR  /* File Manager values */
  #define INCL_DOSFILEMGR  /* File Manager values */
Line 113: Line 106:
     return NO_ERROR;
     return NO_ERROR;
  }
  }
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosClose|DosClose]]
* [[DosClose]]
* [[OS2 API:CPI:DosFindClose|DosFindClose]]
* [[DosFindClose]]
* [[OS2 API:CPI:DosFindFirst|DosFindFirst]]
* [[DosFindFirst]]
* [[OS2 API:CPI:DosQueryFileInfo|DosQueryFileInfo]]
* [[DosQueryFileInfo]]
* [[OS2 API:CPI:DosQueryPathInfo|DosQueryPathInfo]]
* [[DosQueryPathInfo]]
* [[OS2 API:CPI:DosQuerySysInfo|DosQuerySysInfo]]
* [[DosQuerySysInfo]]
* [[OS2 API:CPI:DosResetBuffer|DosResetBuffer]]
* [[DosResetBuffer]]
* [[OS2 API:CPI:DosSearchPath|DosSearchPath]]
* [[DosSearchPath]]
* [[OS2 API:CPI:DosSetFileInfo|DosSetFileInfo]]
* [[DosSetFileInfo]]
* [[OS2 API:CPI:DosSetPathInfo|DosSetPathInfo]]
* [[DosSetPathInfo]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 13:21, 18 November 2016

Description

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>

HDIR      hDir;         /*  The handle of the directory. */
PVOID     pfindbuf;     /*  The address of the directory search information structure. */
ULONG     cbfindbuf;    /*  The length, in bytes, of pfindbuf. */
PULONG    pcFilenames;  /*  Pointer to the number of entries. */
APIRET    ulrc;         /*  Return Code. */

ulrc = 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.

 #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;
    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