Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>_open() open a file for reading or writing</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_open()                  Open a File For Reading or Writing

 #include   <fcntl.h>
 #include   <io.h>

 int        _open(pathname,access);
 char       *pathname;                   Name of file
 int        access;                      Access mode

    _open() opens the file specified by 'pathname', then prepares the
    file for reading and/or writing as defined by 'access'. The value of
    'access' is constructed by combining a constant from the following
    list:

          O_RDONLY          Open for reading only
          O_WRONLY          Open for writing only
          O_RDWR            Open for reading and writing

    along with the following additional values:

          O_NOINHERIT       Included if the file is not to be passed to child
                            programs.
          O_DENYALL         Allows only the current handle to have access to
                            the file.
          O_DENYWRITE       Allows only reads from any other open to the
                            file.
          O_DENYREAD        Allows only writes from any other open to the
                            file.
          O_DENYNONE        Allows other shared opens to the file.

    Only one of the O_DENYxxx values may be included in a single _open()
    under DOS 3.x.  These file-sharing attributes are in addition to any
    locking performed on the files.

    Returns:    On success, the file handle (a non-negative integer) is
                returned. The file pointer that marks the current
                position in the file is set to the beginning of the file.
                On error, -1 is returned and 'errno' (defined in
                <stdlib.h>) is set to one of the following:

          ENOENT            Path or file name not found
          EMFILE            Too many open files
          EACCES            Permission denied
          EINVACC           Invalid access code

See Also: creat() dup() fopen()

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