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/C++ v10.0 : C library - <b>synopsis:</b> 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:

    O_RDONLY
        Read only

    O_WRONLY
        Write only

    O_RDWR
        Both read and write

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

    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:

    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:

    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


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

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, Win, OS/2 1.x(all), OS/2 2.x, NT, DOS/PM

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