delorie.com/djgpp/doc/libc/libc_119.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <fcntl.h> #include <dir.h> #include <io.h> int _creatnew(const char *path, int attrib, int flags); |
This function creates a file given by path and opens it, like
_creat
does, but only if it didn't already exist. If the named
file exists, _creatnew
fails. (In contrast, _creat
opens
existing files and overwrites their contents, see _creat.)
The attributes of the created file are determined by attrib. The
file is usually given the normal attribute (00H). If attrib is
non-zero, additional attributes will be set. The following macros,
defined on <dir.h>
, can be used to control the attributes of the
created file (the associated numeric values appear in parentheses):
FA_RDONLY (1)
FA_HIDDEN (2)
FA_SYSTEM (4)
Other bits (FA_LABEL
and FA_DIREC
) are ignored by DOS.
The argument flags controls the sharing mode and the fine details
of how the file is handled by the operating system. The following
macros, defined on <fcntl.h>
, can be used for this (associated
numeric values are given in parentheses):
SH_COMPAT (00h)
SH_DENYRW (10h)
SH_DENYWR (20h)
SH_DENYRD (30h)
SH_DENYNO (40h)
Note that the file is always open for both reading and writing;
_creatnew
ignores any bits in the lower nibble of flags
(O_RDONLY
, O_WRONLY
, etc.).
_creatnew
calls DOS function 716Ch when long file names are
supported, 6C00h otherwise. (On DOS version 3.x, function 5B00h is
called which ignores the value of flags, since function 6C00h is
only supported by DOS 4.0 and later.)
The file handle returned by _creatnew
is set to binary mode.
This function can be hooked by the Filesystem Extensions handlers, as
described in File System Extensions. If you don't want this, you
should use _dos_creatnew
(see section _dos_creatnew) instead.
The new file descriptor, else -1 on error.
ANSI/ISO C | No |
POSIX | No |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |