mov si, seg ParseInput
mov ds, si
mov si, offset ParseInput ;ds:si points to name(s) to parse
mov di, seg FileFCB
mov es, di
mov di, offset FileFCB ;es:di points to FCB
mov al, ParseControl ;controls parsing
mov ah, 29h ;Parse Filename
int 21h
Parse Filename (Function 29h) converts a filename string of the form drive:filename.extension into a string of the form required for a file control block (FCB).
This function is useful only when file control blocks are used.
ParseInput
Points to a zero-terminated ASCII string specifying the filename or filenames to parse. Each filename must be in the form drive:filename.extension and may contain wildcards. If more than one filename is given, the names must be separated with at least one space character (ASCII 20h). Separator characters used for the MS-DOS command line are also valid.
FileFCB
Points to an FCB structure that receives the parsed filename. 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.”
ParseControl
Controls how MS-DOS parses the ParseInput parameter. This parameter has the following form:
Bit | Meaning |
0 | 0 = Stops parsing if a file separator is encountered. |
1 = Ignores leading separators. | |
1 | 0 = Sets the drive number in the FCB structure to 00h (default drive) if the string does not contain a drive number. |
1 = Leaves the drive number in the FCB structure unchanged if the string does not contain a drive number. | |
2 | 0 = Sets the filename in the FCB structure to eight space characters (ASCII 20h) if the string does not contain a filename. |
1 = Leaves the filename in the FCB structure unchanged if the string does not contain a filename. | |
3 | 0 = Sets the extension in the FCB structure to three space characters (ASCII 20h) if the string does not contain an extension. |
1 = Leaves the extension in the FCB structure unchanged if the string does not contain an extension. |
Bits 4 through 7 are reserved and must be zero.
If the function is successful, the AL, DS:SI, and ES:DI registers contain the following information:
Register | Description |
AL | Contains 01h if at least one wildcard is in the filename or extension. Otherwise, it contains 00h. |
DS:SI | Points to the first character after the parsed string. |
ES:DI | Points to the first byte of the FCB structure. |
If the drive letter is invalid, the AL register contains 0FFh. If the string does not contain a valid filename, the memory at ES:DI+1 contains a space character (ASCII 20h).
Parse Filename fills the fcbDriveId, fcbFileName, and fcbExtent fields of the specified FCB structure unless the ParseControl parameter specifies otherwise. To fill these fields, the function strips any leading white-space characters (spaces and tabs) from the string pointed to by ParseInput, then uses the remaining characters to create the drive number, filename, and filename extension. If bit 0 in ParseControl is set, the function also strips exactly one filename separator if one appears before the first non-white-space character. The following are valid filename separators:
: . ; , = +
Once Parse Filename begins to convert a filename, it continues to read characters from the string until it encounters a white-space character, a filename separator, a control character (ASCII 01h through 1Fh), or one of the following characters:
/ " [ ] < > |
If the filename in the string has fewer than eight characters, the function fills the remaining bytes in the fcbFileName field with space characters (ASCII 20h). If the filename extension has fewer than three characters, the function fills the remaining bytes in the fcbExtent field with space characters.