Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    #include <fcntl.h>
    #include <share.h>
    unsigned _dos_open( char *path,
                        unsigned mode,
                        int *handle );

Description:
    The _dos_open function uses system call 0x3D to open the file specified
    by path, which must be an existing file.  The mode argument specifies
    the file's access, sharing and inheritance permissions.  The access mode
    must be one of:

    Mode     Meaning

O_RDONLY
    Read only

O_WRONLY
    Write only

O_RDWR
    Both read and write

    The sharing permissions, if specified, must be one of:

    Permission     Meaning

SH_COMPAT
    Set compatibility mode.

SH_DENYRW
    Prevent read or write access to the file.

SH_DENYWR
    Prevent write access of the file.

SH_DENYRD
    Prevent read access to the file.

SH_DENYNO
    Permit both read and write access to the file.

    The inheritance permission, if specified, is:

    Permission     Meaning

O_NOINHERIT
    File is not inherited by a child process


Returns:
    The _dos_open function returns zero if successful.  Otherwise, it
    returns an MS-DOS error code and sets  errno to one of the following
    values:

    Constant     Meaning

EACCES
    Access denied because path specifies a directory or a volume ID, or
    opening a read-only file for write access

EINVAL
    A sharing mode was specified when file sharing is not installed, or
    access-mode value is invalid

EMFILE
    No more handles available, (too many open files)

ENOENT
    Path or file not found


Example:
    #include <stdio.h>
    #include <dos.h>
    #include <fcntl.h>
    #include <share.h>

    void main()
      {
        int handle;

        if( _dos_open( "file", O_RDONLY, &handle ) != 0 ) {
            printf( "Unable to open file\n" );
        } else {
            printf( "Open succeeded\n" );
            _dos_close( handle );
        }
      }

Classification:
    DOS

Systems:
    DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32, DOS/PM

See Also:
    _dos_close, _dos_creat, _dos_creatnew, _dos_read, _dos_write, open

See Also: _dos_close _dos_creat

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson