This call opens a new file, an existing file, or a replacement for an existing file. The opened file can have extended attributes.
DosOpen2
FileName (PSZ) - input
Value
Bit
Bit
0001 = Create file if file does not exist.
0001 = Open the file if it already exists.
0010 = Replace the file if it already exists.
Bit
0 = FileName represents a file to be opened in the normal way.
1 = FileName is "Drive:" and represents a mounted disk or diskette volume to be opened for direct access.
0 = Writes to the file may be run through the file system buffer cache.
1 = Writes to the file may go through the file system buffer cache but the sectors are written (actual file I/O completed) before a synchronous write call returns. This state of the file defines it as a synchronous file. For synchronous files, this is a mandatory bit in that the data must be written out to the medium for synchronous write operations.
This bit is not inherited by child processes.
0 = Reported through the system critical error handler.
1 = Reported directly to the caller by way of return code.
Media I/O errors generated through an IOCTL Category 8 function always get reported directly to the caller by way of return code. The Fail-Errors function applies only to non-IOCTL handle-based file I/O calls.
This bit is not inherited by child processes.
0 = It is advisable for the disk driver to cache the data in I/O operations on this file.
1 = I/O to the file need not be done through the disk driver cache.
This bit advises FSDs and device drivers whether it is worth caching the data. Like the write-through bit, this is a per-handle bit and is not inherited by child processes.
0 = File handle is inherited by a spawned process resulting from a DosExecPgm call.
1 = File handle is private to the current process.
This bit is not inherited by child processes.
Sharing Mode
fpGEAList (PGEALIST)
cbList (ULONG)
Flags (BYTE)
Bit
If bit 7 is set to 1, this indicates a critical EA. If bit 7 is 0, this means the EA is noncritical; that is, the EA is not essential to the intended use by an application of the file with which it is associated.
If EABuf is 0x00000000, then no extended attributes are defined for the file.
A successful DosOpen2 request for a file returns a handle to access the file. The read/write pointer is set at the first byte of the file. The pointer's position may be changed by a DosChgFilePtr request or by read and write operations on the file.
The file's date and time can be queried by calling DosQFileInfo, and is set by calling DosSetFileInfo.
FileAttribute sets attribute bits for the file object. Attributes of an existing file can be queried and set by DosQFileMode and DosSetFileMode. A file's read-only attribute may also be set with the OS/2 ATTRIB command.
FileAttribute cannot be set to Volume Label. Volume labels cannot be opened. DosSetFSInfo may be issued with a logical drive number to set volume label information.
The FileSize parameter affects the size of the file only when the file is a new file or a replacement for an existing one. If an existing file is simply opened, FileSize is ignored. DosNewSize may be called to change the existing file's size.
The value in FileSize is a recommended size for the file. If allocation of the full size fails, the open may still succeed. The file system makes a reasonable attempt to allocate the new size in as nearly contiguous an area as possible on the medium. When the file size is extended, the value of the new bytes is undefined.
The DASD Open bit provides direct access to an entire disk or diskette volume, independent of the file system. This mode of opening the volume currently mounted on the drive returns a handle to the caller, which represents the logical volume as a single file. The caller specifies this handle with a DosDevIOCtl Category 8 Function 0 request to block other processes from accessing the logical volume.
The file handle state bits can be set by the DosOpen2 and DosSetFHandState requests. An application can query the file handle state bits as well as the rest of the Open Mode field, by calling DosQFHandState.
Extended attributes can be set by an EAOP structure in EABuf when creating a file, replacing an existing file, or truncating an existing file. No extended attributes are set when simply opening an existing file.
A replace operation is logically equivalent to atomically deleting and re-creating the file. This means that any extended attributes associated with the file are also deleted before the file is re-created.
Family API Considerations
Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following restrictions apply to DosOpen when coding for the DOS mode:
o