#include <fcntl.h> #include <share.h> #include <dos.h> unsigned int _dos_open(const char *filename, unsigned short mode, int *handle);
This is a direct connection to the MS-DOS open function call (%ah = 0x3D). This function opens the given file with the given mode and puts handle of file into handle if openning is successful. Meaning of mode parameter is the following:
Access mode bits (in FCNTL.H):
O_RDONLY (_O_RDONLY) 0x00
O_WRONLY (_O_WRONLY) 0x01
O_RDWR (_O_RDWR) 0x02
Sharing mode bits (in SHARE.H):
SH_COMPAT (_SH_COMPAT) 0x00
SH_DENYRW (_SH_DENYRW) 0x10
SH_DENYWR (_SH_DENYWR) 0x20
SH_DENYRD (_SH_DENYRD) 0x30
SH_DENYNO (_SH_DENYNO) 0x40
Inheritance bits (in FCNTL.H):
O_NOINHERIT (_O_NOINHERIT) 0x80
See section _dos_creat. See section _dos_creatnew. See section _dos_read. See section _dos_write. See section _dos_close
This function does not support long filenames, even on systems where the LFN API (see section _use_lfn) is available. For LFN-aware functions with similar functionality see section _open, section _creat, and section _creatnew. Also see section open, and section creat, which are Posix-standard.
Returns 0 if successful or DOS error code on error (and sets errno to EACCES, EINVAL, EMFILE or ENOENT).
not ANSI, not POSIX
int handle; if ( !_dos_open("FOO.DAT", O_RDWR, &handle) ) puts("Wow, file opening was successful !");
Go to the first, previous, next, last section, table of contents.