DOS Fn 6cH: Extended Open/Create
Compatibility: 4.0+
Expects: AH 6cH
BX extended open mode flags (see below)
CX file attribute (used only if file gets created)
DX action: 00-0h = if file exists, fail the call
00-1h = if file exists, open it
00-2h = if file exists, replace and open it
000-h = if doesn't exist, fail the call
001-h = if doesn't exist, create and open it
DS:SI address of an ASCIIZ▲ string of a filespec to open
──────────────────────────────────────────────────────────────────
Returns: AX error code if CF is set to CY
file handle if no error
CX action taken: 0 file was opened
1 file was created and opened
2 file was replaced and opened
──────────────────────────────────────────────────────────────────
Info: This function opens (or creates and opens) a file. Think of it
as a smart 3dH Open which can optionally 3cH Create the file if
it doesn't exist.
Additionally, this call can disable normal INT 24h critical error
handling and can force all writes to go direct to the disk.
DS:DX points to an ASCIIZ string in the form...
d:\path\filename.ext0
If the drive or path is omitted, defaults are assumed.
BX On entry, BX contains extended mode flags as follows:
1 1 1 1 1 1
╓5┬4┬3┬2┬1┬0┬9┬8╥7┬6┬5┬4┬3┬2┬1┬0╖ See Open Mode for more
║0│d│f│0 0 0 0 0║i│ shr │0│ r/w ║ info on bits 0-7
╙─┴╥┴╥┴─┴─┴─┴─┴─╨╥┴─┴─┴─┴─┴─┴─┴─╜ bits
║ ║ ║ ╚═╦═╝ ╚═══╩═► 0-2: read/write access mode
║ ║ ║ ╚═══════════► 4-6: sharing mode
║ ║ ╚═══════════════► 7: inheritance
║ ╚═══════════════════════════► 13: 0=normal INT 24H use
║ 1=fail critical errors
║ on open and all I/O
╚═════════════════════════════► 14: 0=normal file buffering
1=directly to disk
If bit 13 is set (2000H), then I/O through this handle will never
cause an INT 24H critical error. If a drive door is open (etc.),
then the function which caused the error will fail with a regular
DOS error. Use Fn 59H to find out what happened.
If bit 14 is set (4000H), then the normal DOS output buffering is
bypassed and all output goes directly to the disk (as if you had
called Fn 68H after each write). This can hurt I/O performance,
but it maximizes safety.
CX When creating a new file, set CX to the desired file attribute
(read-only, hidden, etc.). Use 0000H for normal files. If the
file exists, CX is ignored.
DX This controls the open/create action, depending upon whether the
file exists at the time of the call. Common combinations are:
0001H = open the file if it exists; otherwise fail the call
0011H = open the file if it exists; otherwise create it
0012H = if the file exists open and truncate it to length 0;
otherwise create it and open it
Notes: ■ Perhaps the most useful feature here is the ability to avoid
special handling for INT 24H critical errors. Of course, you
can only discard your INT 24H handler if you are sure that the
application is used only under DOS 4.0+.
See Also: Handle-Oriented File I/O
INT 24H
DOS Functions
-♦-