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

Method fdFdstatSetFlags

lib/host/wasi/inode-win.cpp:827–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

825}
826
827WasiExpect<void>
828INode::fdFdstatSetFlags(__wasi_fdflags_t FdFlags) const noexcept {
829 auto This = const_cast<INode *>(this);
830 if (Type == HandleType::NormalSocket) {
831 // Support __WASI_FDFLAGS_NONBLOCK only, ignore other flags.
832 if ((This->SavedFdFlags ^ FdFlags) & __WASI_FDFLAGS_NONBLOCK) {
833 const bool NonBlock = FdFlags & __WASI_FDFLAGS_NONBLOCK;
834 u_long SysFlag = NonBlock ? 1 : 0;
835 if (auto Res = ioctlsocket(Socket, FIONBIO, &SysFlag);
836 unlikely(Res == SOCKET_ERROR_)) {
837 return WasiUnexpect(detail::fromWSALastError());
838 }
839 if (NonBlock) {
840 This->SavedFdFlags |= __WASI_FDFLAGS_NONBLOCK;
841 } else {
842 This->SavedFdFlags &= ~__WASI_FDFLAGS_NONBLOCK;
843 }
844 }
845 return {};
846 }
847 // Support __WASI_FDFLAGS_APPEND only, ignore other flags.
848 if ((This->SavedFdFlags ^ FdFlags) & __WASI_FDFLAGS_APPEND) {
849 const bool Append = FdFlags & __WASI_FDFLAGS_APPEND;
850 if (Append) {
851 This->SavedFdFlags |= __WASI_FDFLAGS_APPEND;
852 } else {
853 This->SavedFdFlags &= ~__WASI_FDFLAGS_APPEND;
854 }
855 }
856 return {};
857}
858
859WasiExpect<void>
860INode::fdFilestatGet(__wasi_filestat_t &FileStat) const noexcept {

Callers 1

bodyMethod · 0.45

Calls 3

unlikelyFunction · 0.85
WasiUnexpectFunction · 0.85
fromWSALastErrorFunction · 0.85

Tested by

no test coverage detected