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

Method open

lib/host/wasi/inode-linux.cpp:187–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185WasiExpect<INode> INode::fromFd(int32_t Fd) { return createStdNode(Fd); }
186
187WasiExpect<INode> INode::open(std::string Path, __wasi_oflags_t OpenFlags,
188 __wasi_fdflags_t FdFlags,
189 VFS::Flags VFSFlags) noexcept {
190 const int Flags = openFlags(OpenFlags, FdFlags, VFSFlags);
191
192 if (auto NewFd = ::open(Path.c_str(), Flags, 0644); unlikely(NewFd < 0)) {
193 return WasiUnexpect(fromErrNo(errno));
194 } else {
195 INode New(NewFd);
196
197#ifndef O_CLOEXEC
198 if (auto Res = ::fcntl(New.Fd, F_SETFD, FD_CLOEXEC); unlikely(Res != 0)) {
199 return WasiUnexpect(fromErrNo(errno));
200 }
201#endif
202 return New;
203 }
204}
205
206WasiExpect<void> INode::fdAdvise(__wasi_filesize_t Offset,
207 __wasi_filesize_t Len,

Callers

nothing calls this directly

Calls 5

unlikelyFunction · 0.85
WasiUnexpectFunction · 0.85
c_strMethod · 0.80
openFlagsFunction · 0.70
fromErrNoFunction · 0.70

Tested by

no test coverage detected