GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
fcntl.c
Go to the documentation of this file.
1/*!
2 * \file msvc/fcntl.c
3 *
4 * \brief Wrapper functions for MSVC _open() and _creat() that convert
5 * permission mode.
6 *
7 * (C) 2025 by the GRASS Development Team
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 *
11 * \author Huidae Cho
12 *
13 * \date 2025
14 */
15
16#include <stdarg.h>
17#include <fcntl.h>
18#include <sys/stat.h>
19
20#define O_TMPFILE O_TEMPORARY
21
22int __open(const char *pathname, int flags, ...)
23{
24 if (flags & (O_CREAT | O_TMPFILE)) {
25 va_list ap;
26 int mode;
27
28 va_start(ap, flags);
29 mode = va_arg(ap, int);
30 va_end(ap);
31
32 return _open(pathname, flags,
33 (mode & 0400 ? _S_IREAD : 0) |
34 (mode & 0200 ? _S_IWRITE : 0));
35 }
36
37 return _open(pathname, flags);
38}
39
40int __creat(const char *pathname, int mode)
41{
42 return _creat(pathname,
43 (mode & 0400 ? _S_IREAD : 0) | (mode & 0200 ? _S_IWRITE : 0));
44}
#define O_TMPFILE
Definition fcntl.c:20
int __creat(const char *pathname, int mode)
Definition fcntl.c:40
int __open(const char *pathname, int flags,...)
Definition fcntl.c:22
Header file for msvc/fcntl.c.