MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __wasi_fd_close

Function __wasi_fd_close

system/lib/wasmfs/syscalls.cpp:283–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283__wasi_errno_t __wasi_fd_close(__wasi_fd_t fd) {
284 std::shared_ptr<DataFile> closee;
285 {
286 // Do not hold the file table lock while performing the close.
287 auto fileTable = wasmFS.getFileTable().locked();
288 auto entry = fileTable.getEntry(fd);
289 if (!entry) {
290 return __WASI_ERRNO_BADF;
291 }
292 closee = fileTable.setEntry(fd, nullptr);
293 }
294 if (closee) {
295 // Translate to WASI standard of positive return codes.
296 int ret = -closee->locked().close();
297 assert(ret >= 0);
298 return ret;
299 }
300 return __WASI_ERRNO_SUCCESS;
301}
302
303__wasi_errno_t __wasi_fd_sync(__wasi_fd_t fd) {
304 auto openFile = wasmFS.getFileTable().locked().getEntry(fd);

Callers

nothing calls this directly

Calls 5

getEntryMethod · 0.80
setEntryMethod · 0.80
assertFunction · 0.50
lockedMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected