MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / openFlags

Function openFlags

lib/host/wasi/inode-macos.cpp:53–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51};
52
53constexpr int openFlags(__wasi_oflags_t OpenFlags, __wasi_fdflags_t FdFlags,
54 VFS::Flags VFSFlags) noexcept {
55 int Flags = O_CLOEXEC | O_NOFOLLOW;
56
57 if (VFSFlags & VFS::Read) {
58 if (VFSFlags & VFS::Write) {
59 Flags |= O_RDWR;
60 } else {
61 Flags |= O_RDONLY;
62 }
63 } else if (VFSFlags & VFS::Write) {
64 Flags |= O_WRONLY;
65 } else {
66 Flags |= O_RDONLY;
67 }
68
69 if (OpenFlags & __WASI_OFLAGS_CREAT) {
70 Flags |= O_CREAT;
71 }
72 if (OpenFlags & __WASI_OFLAGS_DIRECTORY) {
73 Flags |= O_DIRECTORY;
74 }
75 if (OpenFlags & __WASI_OFLAGS_EXCL) {
76 Flags |= O_EXCL;
77 }
78 if ((OpenFlags & __WASI_OFLAGS_TRUNC) && (VFSFlags & VFS::Write)) {
79 Flags |= O_TRUNC;
80 }
81
82 // Convert file descriptor flags.
83 if ((FdFlags & __WASI_FDFLAGS_APPEND) != 0) {
84 Flags |= O_APPEND;
85 }
86 if ((FdFlags & (__WASI_FDFLAGS_DSYNC | __WASI_FDFLAGS_RSYNC |
87 __WASI_FDFLAGS_SYNC)) != 0) {
88 Flags |= O_SYNC;
89 }
90 if ((FdFlags & __WASI_FDFLAGS_NONBLOCK) != 0) {
91 Flags |= O_NONBLOCK;
92 }
93
94 return Flags;
95}
96
97std::pair<const char *, std::unique_ptr<char[]>>
98createNullTerminatedString(std::string_view View) noexcept {

Callers 2

openMethod · 0.70
pathOpenMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected