Function 4Fh Find Next File

mov ah, 4Fh ;Find Next File

int 21h

jc error_handler ;carry set means error

Find Next File (Function 4Fh) searches for the next directory entry that matches the name and attributes specified in a previous call to Find First File (Function 4Eh). The current disk transfer address (DTA) must contain the information filled in by the Find First File function.

Parameters

This function has no parameters.

Return Value

If the function is successful, the carry flag is clear and the file information is copied as a FILEINFO structure to the current DTA. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following:

Value Name

0002h ERROR_FILE_NOT_FOUND
0003h ERROR_PATH_NOT_FOUND
0012h ERROR_NO_MORE_FILES

Comments

If a program specifies any combination of ATTR_SYSTEM, ATTR_HIDDEN, and ATTR_DIRECTORY, this function returns normal files as well as the specified files. The program must examine the attribute contained in the DTA to determine the type of file found.

The FILEINFO structure that contains the file information has the following form:

FILEINFO STRUC

fiReserved db 21 dup (?) ;reserved

fiAttribute db ? ;attributes of file found

fiFileTime dw ? ;time of last write

fiFileDate dw ? ;date of last write

fiSize dd ? ;file size

fiFileName db 13 dup (?) ;filename and extension

FILEINFO ENDS

For a full description of the FILEINFO structure, see Chapter 3, “File System.”

See Also

Function 4Eh Find First File