solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
wintypes.h
Go to the documentation of this file.
1
6#ifndef FLAGS_H
7#define FLAGS_H
8
9#ifdef _WIN32
10#include <direct.h> // _mkdir (actual declaration)
11#include <fcntl.h> // O_* flags and _O_* flags
12#include <io.h> // _open, _read, _write, _close, _get_osfhandle
13#include <sys/stat.h> // _S_IF*, _S_IREAD, _S_IWRITE, _mkdir
14#include <sys/types.h> // mode_t
15#include <windows.h> // Windows HANDLE, etc.
16
17// Must come after windows.
18#include <wincrypt.h> // For Cryptographic functions on windows
19
20// File access flags
21#define O_RDONLY _O_RDONLY
22#define O_WRONLY _O_WRONLY
23#define O_RDWR _O_RDWR
24#define O_APPEND _O_APPEND
25#define O_CREAT _O_CREAT
26#define O_TRUNC _O_TRUNC
27#define O_EXCL _O_EXCL
28#define O_TEXT _O_TEXT
29#define O_BINARY _O_BINARY
30#define O_RAW _O_BINARY
31#define O_TEMPORARY _O_TEMPORARY
32#define O_NOINHERIT _O_NOINHERIT
33#define O_SEQUENTIAL _O_SEQUENTIAL
34#define O_RANDOM _O_RANDOM
35#define O_ACCMODE _O_ACCMODE
36
37// File type flags
38#define S_IFMT _S_IFMT
39#define S_IFDIR _S_IFDIR
40#define S_IFCHR _S_IFCHR
41#define S_IFIFO _S_IFIFO
42#define S_IFREG _S_IFREG
43
44// File type check macros
45#ifndef S_ISDIR
46#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
47#endif
48
49#ifndef S_ISREG
50#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
51#endif
52
53#ifndef S_ISCHR
54#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
55#endif
56
57#ifndef S_ISFIFO
58#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
59#endif
60
61// Permission flags
62#define S_IREAD _S_IREAD
63#define S_IWRITE _S_IWRITE
64#define S_IEXEC _S_IEXEC
65
66// Directory creation
67#define MKDIR(path) _mkdir(path)
68
69#else // POSIX systems
70
71#include <dirent.h>
72#include <fcntl.h>
73#include <sys/stat.h>
74#include <sys/types.h>
75#include <unistd.h>
76
77// Directory creation
78#define MKDIR(path) mkdir((path), 0755)
79
80#endif // _WIN32
81
82#endif // FLAGS_H