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

Function openFileForWrite

test/host/wasi/wasi.cpp:4262–4275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4260namespace {
4261namespace fs = std::filesystem;
4262int openFileForWrite(const fs::path &Filename) {
4263 int Fd = -1;
4264 const std::string PathStr = Filename.u8string();
4265#if WASMEDGE_OS_WINDOWS
4266 if (_sopen_s(&Fd, PathStr.c_str(),
4267 _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, _SH_DENYNO,
4268 _S_IREAD | _S_IWRITE) != 0) {
4269 return -1;
4270 }
4271#else
4272 Fd = open(PathStr.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
4273#endif
4274 return Fd;
4275}
4276
4277int openFileForRead(const fs::path &Filename) {
4278 int Fd = -1;

Callers 1

TESTFunction · 0.85

Calls 1

c_strMethod · 0.80

Tested by

no test coverage detected