home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / SYS / OPEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  670 b   |  27 lines

  1. /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <os2emx.h>
  5. #include "syscalls.h"
  6.  
  7. int __open (const char *name, int flags)
  8. {
  9.   ULONG rc;
  10.   ULONG mode, attr, action, open_mode;
  11.   HFILE handle;
  12.  
  13.   mode = flags & 0x77;
  14.   attr = (flags >> 8) & 0xff;
  15.   if (flags & 0x10000)
  16.     open_mode = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
  17.   else
  18.     open_mode = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
  19.   rc = DosOpen (name, &handle, &action, 0, attr, open_mode, mode, NULL);
  20.   if (rc != 0)
  21.     {
  22.       _sys_set_errno (rc);
  23.       return (-1);
  24.     }
  25.   return (handle);
  26. }
  27.