Function 11h Find First File with FCB

mov dx, seg FileFCB

mov ds, dx

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

mov ah, 11h ;Find First File with FCB

int 21h

cmp al, 0 ;zero means success

jne error_handler

Find First File with FCB (Function 11h) searches the current directory for the first file matching the filename specified by the file control block (FCB).

This function has been superseded by Find First File (Function 4Eh).

Parameter

FileFCB

Points to an FCB structure or EXTENDEDFCB structure that identifies the file or files to search for.

If an FCB structure is given, the fcbDriveID, fcbFileName, and fcbExtent fields must specify the filename(s). The filename can include wildcards. All other fields should be zero. 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.”

If an EXTENDEDFCB structure is given, the extDriveID, extFileName, and extExtent fields must specify the filename(s). The filename can include wildcards. The extAttribute field must specify the attributes of the file to search for. All other fields should be zero. 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 a program uses Find Next File with FCB (Function 12h) to continue searching for matching filenames, it must not alter or open the original FCB structure.

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 4Eh Find First File