DosFindFirst2
Description
This call finds the first file object or group of file objects whose name(s) match the specification. The specification can include extended attribute information associated with a file or subdirectory.
Syntax
DosFindFirst2 (FileName, DirHandle, Attribute, ResultBuf, ResultBufLen, SearchCount, FileInfoLevel, Reserved)
Parameters
- FileName (PSZ) - input
- Address of the ASCIIZ path name of the file or subdirectory to be found. The name component may contain global file name characters.
- DirHandle (PHDIR) - input/output
- Address of the handle associated with a specific DosFindFirst2 request. The values that can be specified are:
- 0001H The system assigns the handle for standard output, which is always available to a process.
- FFFFH The system allocates and returns a handle. If on input FFFFH is specified, on output DirHandle contains the handle allocated by the system.
The DosFindFirst2 handle is used with subsequent DosFindNext requests. Reuse of this handle in another DosFindFirst2 closes the association with the previous DosFindFirst2 and opens a new association.
- Attribute (USHORT) - input
- Attribute value that determines the file objects to be searched for.
Bit Description 15-6 Reserved and must be zero. 5 File archive 4 Subdirectory 3 Reserved and must be zero. 2 System file 1 Hidden file 0 Read only file
These bits may be set individually or in combination. For example, an attribute value of 0021H (bits 5 and 0 set to 1) indicates a read-only file that should be archived.
To look at all directory entries except the volume label, set Attribute to hidden+system+directory (all three bits on). Attribute cannot specify the volume label. Volume labels are queried using DosQFSInfo.
If Attribute is 0, only normal file entries are found. Entries for subdirectories, hidden, and system files, are not returned.
- ResultBuf (PVOID) - input/output
- Address of the directory search structures for file object information levels 1 through 3. The structure required for ResultBuf is dependent on the value specified for FileInfoLevel. The information returned reflects the last DosSetFileInfo, DosSetPathInfo, DosClose, and DosBufReset calls.
Level 1 Information ResultBuf contains the following structure, to which directory entry information is returned:
- filedate (FDATE) : Structure containing the date of file creation.
Bit Description 15-9 Year, in binary, of file creation 8-5 Month, in binary, of file creation 4-0 Day, in binary, of file creation.
- filetime (FTIME) : Structure containing the time of file creation.
Bit Description 15-11 Hours, in binary, of file creation 10-5 Minutes, in binary, of file creation 4-0 Seconds, in binary number of two-second increments, of file creation.
fileaccessdate (FDATE)
Structure containing the date of last access. See FDATE in filedate.
fileaccesstime (FTIME)
Structure containing the time of last access. See FTIME in filetime.
writeaccessdate (FDATE)
Structure containing the date of last write. See FDATE in filedate.
writeaccesstime (FTIME)
Structure containing the time of last write. See FTIME in filetime.
filesize (ULONG)
File size.
filealloc (ULONG)
Allocated file size.
fileattrib (USHORT)
Attributes of the file, defined in DosSetFileMode.
length (UCHAR)
Length of the ASCIIZ name string.
matchfilename (CHAR)
ASCIIZ name string for the first occurrence of FileName.
Level 2 Information ResultBuf contains a structure similar to the Level 1 structure, with the addition of the cbList field inserted before the name length field of the matched file object.
cbList (ULONG) : On output, this field contains the length of the entire EA set for the file object. This value can be used to calculate the size of the buffer required to hold EA information returned when FileInfoLevel = 3 is specified.
Level 3 Information
ResultBuf contains an EAOP structure, which has the following format :
fpGEAList (PGEALIST): Address of GEAList. GEAList is a packed array of variable length "get EA" structures, each containing an EA name and the length of the name.
fpFEAList (PFEALIST): Address of FEAList. FEAList is a packed array of variable length "full EA" structures, each containing an EA name and its corresponding value, as well as the lengths of the name and the value.
oError (ULONG): Offset into structure where error has occurred.
On input, fpGEAList contains the address of a GEA list, which defines the attribute names whose values are to be returned. fpGEAList is ignored. In case of error, oError contains the offset of the offending GEA entry. Following is the format of the GEAList structure:
cbList (ULONG): Length of the GEA list, including the length itself. list (GEA)
List of GEA structures. A GEA structure has the following format:
- cbName (BYTE) : Length of EA ASCIIZ name, which does not include the null character.
- szName (CHAR) : ASCIIZ name of EA.
Following the EAOP structure is a structure similar to the Level 1 structure, with the addition of an FEAList structure inserted before the name length field for the matched file object.
n output, this structure contains a packed set of records representing the directory entry and associated EAs for the matched file object. Following is the format of the FEAList structure:
cbList (ULONG): Length of the FEA list, including the length itself.
list (FEA) List of FEA structures. An FEA structure has the following format:
Flags (BYTE) : Bit indicator describing the characteristics of the EA being defined.
Bit Description 7 Critical EA. 6-0 Reserved and must be set to zero.
If bit 7 is set to 1, this indicates a critical EA. If bit 7 is 0, this means the EA is noncritical; that is, the EA is not essential to the intended use by an application of the file with which it is associated.
cbName (BYTE) : Length of EA ASCIIZ name, which does not include the null character.
cbValue (USHORT) : Length of EA value, which cannot exceed 64KB.
szName (PSZ) : ASCIIZ name of EA.
aValue (PSZ) : Free-format value of EA.
Note: The szName and aValue fields are not included as part of header or include files. Because of their variable lengths, these entries must be built manually.
- ResultBufLen (USHORT) - input
- Length of ResultBuf. SearchCount (PUSHORT) - input/output
Address of the number of matching entries requested in ResultBuf. On return, this field contains the number of entries placed into ResultBuf.
- FileInfoLevel (USHORT)
- The level of file information required. A value of 1, 2, or 3 can be specified. The structures described in ResultBuf indicate the information returned for each of these levels.
Regardless of the level specified, a DosFindFirst2 request (and an associated DosFindNext request) always includes the information returned by level 1 as part of the information that is returned. However, when level 1 information is specifically requested, an inclusive search is made. That is, all normal file entries plus all entries matching any specified attributes are returned.
- Reserved (ULONG) - input
- Reserved, must be set to zero.
Return Code
Remarks
Example Code
C Binding
MASM Binding
Related Functions
- [[OS2 API:CPI: