Get file attributes





QuickBasic


' DOS 2+ - GET FILE ATTRIBUTES
' read-only and hidden do not work in DOSBox

'$INCLUDE: 'qb.bi'

DIM inregs  AS RegTypeX
DIM outregs AS RegTypeX

DIM atr AS STRING
DIM byte AS INTEGER
DIM filename AS STRING

filename = "C:\INT\125.txt" + CHR$(0)
inregs.DS = VARSEG(filename)
inregs.DX = SADD(filename)
inregs.AX = &H4300

' DOS interrupt with sub-function &H43
CALL INTERRUPTX(&H21, inregs, outregs)

byte = outregs.CX  ' File Attributes

IF (byte AND 128) THEN atr = atr + "Sharable, pending deleted files" + CHR$(10)
IF (byte AND 32) THEN atr = atr + "Archive" + CHR$(10)
IF (byte AND 16) THEN atr = atr + "Directory" + CHR$(10)
IF (byte AND 8) THEN atr = atr + "Volume Label" + CHR$(10)
IF (byte AND 4) THEN atr = atr + "System" + CHR$(10)
IF (byte AND 2) THEN atr = atr + "Hidden" + CHR$(10)
IF (byte AND 1) THEN atr = atr + "Read-Only" + CHR$(10)

IF outregs.flags AND 1 THEN
   PRINT "Error getting file attributes >> " + filename
   BEEP: END
END IF

PRINT "The File Attributes are: "; CHR$(10); atr