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