home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / creat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-21  |  985 b   |  32 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. int creat(filename, pmode)
  5. register char *filename;
  6. register int pmode;
  7. /*
  8.  *    Create a new file with the given <filename>.  If a file with
  9.  *    the name already exists, it will be truncated to zero bytes.
  10.  *    Since the OS doesn't do this properly, the file is actually
  11.  *    deleted and then re-created.  <pmode> specifies the attributes
  12.  *    initially given to the file.  Valid <pmode> values are:
  13.  *        _CRErw        read/write
  14.  *        _CREro        read only
  15.  *        _CREh        hidden file
  16.  *        _CREs        system file
  17.  *        _CREv        volume label
  18.  *    If _CRErw or _CREv modes are specified, they must be the only
  19.  *    mode given.  Other modes may be combined with the | operator.
  20.  *
  21.  *    Implementation Note:  File is deleted first to avoid a TOS bug
  22.  *    that allows creation of duplicate file names.
  23.  */
  24. {
  25.     register int rv;
  26.  
  27.     rv = Fdelete(filename);
  28.     if((rv == 0) || (rv == -33))    /* SUCCESS or FILE-NOT-FOUND */
  29.         rv = Fcreate(filename, pmode);
  30.     return(rv);
  31. }
  32.