qc.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
creat
 Summary Example                         Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     The creat function either creates a new file or opens and
     truncates an existing file. If the file specified by <filename>
     does not exist, a new file is created with the given permission
     setting and is opened for writing. If the file already exists and
     its permission setting allows writing, creat truncates the file to
     length 0, destroying the previous contents, and opens it for
     writing.
 
     The permission setting, <pmode>, applies to newly created files
     only. The new file receives the specified permission setting after
     it is closed for the first time. The integer expression <pmode>
     contains one or both of the manifest constants S_IWRITE and
     S_IREAD, defined in SYS\STAT.H. When both constants are given,
     they are joined with the bitwise-OR operator (|). The meaning of
     the <pmode> argument is determined by the S_IWRITE or S_IREAD
     manifest constant.
 
     If write permission is not given, the file is read-only. Under DOS
     and OS/2, it is not possible to give write-only permission.
     Therefore, the modes S_IWRITE and S_IREAD | S_IWRITE are
     equivalent. Under MS-DOS versions 3.0 and later, files opened
     using creat are always opened in compatibility mode (see sopen).
 
     The creat function applies the current file-permission mask to
     <pmode> before setting the permissions (see umask).
 
     Note that the creat routine is provided primarily for
     compatibility with previous libraries. A call to open with O_CREAT
     and O_TRUNC in the <oflag> argument is equivalent to creat and is
     preferable for new code.
 
     Return Value
 
     If successful, creat returns a handle for the created file.
     Otherwise, it returns -1 and sets errno to EACCES, EMFILE,
     or ENOENT.
                                    -♦-