Function 4300h Get File Attributes

mov dx, seg FileName

mov ds, dx

mov dx, offset FileName ;ds:dx points to filename or directory name

mov ax, 4300h ;Get File Attributes

int 21h

jc error_handler ;carry set means error

mov Attributes, cx ;attributes are returned in cx

Get File Attributes (Function 4300h) retrieves the attributes for a specified file or directory.

Parameter

FileName

Points to a zero-terminated ASCII string that specifies the file or directory to retrieve attributes for. This string must be a valid MS-DOS filename or directory name and cannot contain wildcards.

Return Value

If the function is successful, the carry flag is clear and the CX register contains the attributes for the file or directory. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following values:

Value Name

0001h ERROR_INVALID_FUNCTION
0002h ERROR_FILE_NOT_FOUND
0003h ERROR_PATH_NOT_FOUND
0005h ERROR_ACCESS_DENIED

Comment

The file attributes returned in the CX register may be a combination of the following values:

Value Meaning

ATTR_NORMAL (0000h) File can be read from or written to.
ATTR_READONLY (0001h) File can read from but not written to.
ATTR_HIDDEN (0002h) File or directory is hidden and does not appear in a directory listing.
ATTR_SYSTEM (0004h) File or directory is a system file.
ATTR_ARCHIVE (0020h) File has been archived.
ATTR_VOLUME (0008h) Filename is the current volume label for the media.
ATTR_DIRECTORY (0010h) Filename identifies a directory, not a file.

See Also

Function 4301h Set File Attributes