File and Path Function
int creat(const char *filename, mode_t pmode);
int _creat(const char *filename, int pmode);
int _wcreat(const wchar_t *filename, int pmode);
int _tcreat(const TCHAR *filename, int pmode);
Internationalization (I18n) Function Overview
The creat and _creat functions create a new file or open and truncate an existing one with the name filename and the permissions indicated by pmode .
If successful, the return is a file descriptor to the created file. Otherwise, the return is -1 and the global variable errno indicates the specific error.
The pmode argument can be set to one of the following permissions:
_S_IWRITE to permit writing to the file;
_S_IREAD to permit reading from the file;
_S_IREAD | _S_IWRITE - to permit both file input and output.
The permission setting applies to newly created files only.
If the file already exists and its permission setting allows writing, the function truncates the file to length 0, destroying the previous contents, and opens it for writing.
On Windows platforms, _wcreat is the wide-character version of _creat ; its argument is a wide-character string. There is no ANSI wide-character equivalent.
_tcreat is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _creat or _wcreat .
I18n Issues
Use the appropriate version of the function as required for internationalization support, noting the following:
This function and its variations are considered obsolete and should be replaced with an open function call.
Otherwise, on ANSI UTF-16 platforms, use a conversion function to convert the
wide-character string to a multibyte-character string and then call creat .
See Pathnames for a discussion of path and filename considerations in
an internationalized application, and File I/O, which addresses reading and
writing non-ASCII text data files.
Recommended Replacements*
As mentioned above, when possible, call a variant of the open function.
These are shown as the first choices in the following table:
*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.
File and Path Functions
|