Function 12h Find Next File with FCB

mov dx, seg FileFCB

mov ds, dx

mov dx, offset FileFCB ;ds:dx points to FCB

mov ah, 12h ;Find Next File with FCB

int 21h

cmp al, 0 ;zero means success

jne error_handler

Find Next File with FCB (Function 12h) searches the current directory for additional files matching the filename specified by the file control block (FCB).

A program must initiate a file search with Find First File with FCB (Function 11h) before it can use Find Next File with FCB.

This function has been superseded by Find Next File (Function 4Fh).

Parameter

FileFCB

Points to an FCB structure or EXTENDEDFCB structure that identifies the file or files to search for. The structure must have been previously filled by using Find First File with FCB (Function 11h). The FCB structure has the following form:

FCB STRUC

fcbDriveID db ? ;drive no. (0=default, 1=A, etc.)

fcbFileName db '????????' ;filename

fcbExtent db '???' ;file extension

fcbCurBlockNo dw ? ;current block number

fcbRecSize dw ? ;record size

fcbFileSize db 4 dup (?) ;size of file in bytes

fcbFileDate dw ? ;date file last modified

fcbFileTime dw ? ;time file last modified

fcbReserved db 8 dup (?) ;reserved

fcbCurRecNo db ? ;current record number

fcbRandomRecNo db 4 dup (?) ;random record number

FCB ENDS

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

The EXTENDEDFCB structure has the following form:

EXTENDEDFCB STRUC

extSignature db 0ffh ;extended FCB signature

extReserved db 5 dup(0) ;reserved bytes

extAttribute db ? ;attribute byte

;file control block (FCB)

extDriveID db ? ;drive no. (0=default, 1=A, etc.)

extFileName db '????????' ;filename

extExtent db '???' ;file extension

extCurBlockNo dw ? ;current block number

extRecSize dw ? ;record size

extFileSize db 4 dup (?) ;size of file, in bytes

extFileDate dw ? ;date file last modified

extFileTime dw ? ;time file last modified

extReserved db 8 dup (?) ;reserved bytes

extCurRecNo db ? ;current record number

extRandomRecNo db 4 dup (?) ;random record number

EXTENDEDFCB ENDS

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

Return Value

If a file matching the name in the FCB structure or EXTENDEDFCB structure is found, the AL register contains 00h and the buffer at the current disk transfer address (DTA) receives a DIRENTRY structure defining the file. Otherwise, the AL register contains 0FFh.

Comments

If the function is successful and an FCB structure was given, the function copies the drive number used in the search (1 = A, 2 = B, and so on) to the first byte at the DTA. It copies a DIRENTRY structure defining the file starting at the second byte at the DTA.

If the function is successful and an EXTENDEDFCB was given, the function copies an EXTHEADER structure starting at the first byte at the DTA and then copies a DIRENTRY structure defining the file immediately after the EXTHEADER structure.

The DIRENTRY structure has the following form:

DIRENTRY STRUC

deName db '????????' ;name

deExtension db '???' ;extension

deAttributes db ? ;attributes

deReserved db 10 dup(?) ;reserved

deTime dw ? ;time

deDate dw ? ;date

deStartCluster dw ? ;starting cluster

deFileSize dd ? ;file size

DIRENTRY ENDS

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

The EXTHEADER structure has the following form:

EXTHEADER STRUC

ehSignature db 0ffh ;extended signature

ehReserved db 5 dup(0) ;reserved

ehSearchAttrs db ? ;attribute byte

EXTHEADER ENDS

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

See Also

Function 4Fh Find Next File