FCB: File Control Block
FcbRec
Offset Size Contents
▀▀▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
+0 1 bDrvID drive ID (see below)
+1 8 abName left-justified, blank-padded (e.g. 'FILE '
+9 3 abExt left-justified, blank-padded (e.g. 'EXT'
+0cH 2 wCurBlock current block number
+0eH 2 wRecSize logical record size
+10H 4 lFileSize length of file
+14H 2 rDate Date created/last modified in FileTimeRec format
+14H 2 rTime Time created/last modified in FileDateRec format
+16H 8 res (reserved, undocumented)
+20H 2 wCurRecNo current position in current block (0-7fH)
+21H 4 lRndmRecNo current record number in entire file
37 size of an FcbRec
bDrvID Drive number. Before open: 0=default, 1=A, 2=B, etc.
After open: 0=A, 1=B, etc.)
abName Filename. If fewer than 8 characters, it is padded to 8 with
spaces (20H)
abExt File extension. If fewer than 3 characters, it is padded to 3
with spaces (30H)
wCurBlock Current block number (a block is 128 records). DOS sets to 0
when the file is opened
wRecSize Size of a record, in bytes. DOS sets to 128 on open.
lFileSize Total size of the file, in bytes
rDate File date in special format. See FileDateRec
rTime File time in special format. See FileTimeRec
wCurRecNo position within the current record (wCurRec)
lRndmRecNo file position, specified as a number of records from the start
of the file.
Notes: ■ FCBs are obsolete, but still supported by DOS. There is no
need to use this structure at all.
■ Unopened FCB: Before opening a file, you need only supply
bDrvID, abName, and abExt (e.g.: 0,'MYFILE TXT') and leave
room for DOS to fill in the other fields.
■ Opened FCB: After successfully opening an FCB, the bDrvID
contains a non-zero drive number (A=1, B=3, etc), other fields
have been set up for access to the start of the file.
■ I won't bother covering the arcane system of block-and-record
bookkeeping used to position the file pointer. R.I.P.
■ In order to open files that have a particular file attribute,
you must use an Extended FCB...
FcbExtendedRec
Offset Size Contents
▀▀▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-7 1 bSig ffH (signature indicates Extended FCB)
-6 5 res reserved
-1 1 bAttr file attribute
+0 1 bDrvID drive ID (see below)
.
. (other fields as above)
.
...that is simply an FcbRec, preceded by 7 bytes, with [FCB-7]
being 0ffH and [FCB-1] being the file attribute. Weird, huh?
See Also: FCB File I/O
Data Structures
-♦-