Function 10h Close File with FCB

mov dx, seg FileFCB

mov ds, dx

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

mov ah, 10h ;Close File with FCB

int 21h

cmp al, 0 ;zero means success

jne error_handler

Close File with FCB (Function 10h) closes the open file identified by the file control block (FCB).

This function has been superseded by Close File with Handle (Function 3Eh).

Parameter

FileFCB

Points to an FCB structure that identifies the file to close. The structure must have been previously opened by using Open File with FCB (Function 0Fh) or Create File with FCB (Function 16h). 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.”

Return Value

If the file is found, the AL register contains 00h and the remaining fields in the FCB structure are filled in. Otherwise, the AL register contains 0FFh.

Comments

Close File with FCB searches the current directory for the file named in the FCB structure. If it finds a directory entry for the file, it completes any buffered write operations (buffered information is written to the disk, and the buffers are freed). MS-DOS then updates the directory entry, if necessary, to match the FCB structure and closes the file. Further requests to read from or write to the file will fail.

After a program changes a file, it must call this function to update the directory entry. Programs should close any FCB structure (even one for a file that has not been changed) when they no longer need access to the file.

This function does not support paths, so it is possible to close only files in the current directory.

See Also

Function 0Fh Open File with FCB
Function 3Eh Close File with Handle