MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / fs_stat

Function fs_stat

host/sysenv/sys_fs.cpp:162–176  ·  view source on GitHub ↗

stat(path_ptr, path_len, stat_buf) -> i32

Source from the content-addressed store, hash-verified

160
161// stat(path_ptr, path_len, stat_buf) -> i32
162static std::vector<Value> fs_stat(Stack& stack) {
163 Frame& frame = stack.frames.top();
164 i64_t path_ptr = get_ptr(frame.locals[0]);
165 i64_t path_len = get_ptr(frame.locals[1]);
166 i64_t stat_buf = get_ptr(frame.locals[2]);
167 try {
168 std::string path = mem_string(stack, path_ptr, path_len);
169 stat_t st;
170 if(sys_stat(path.c_str(), &st) != 0) return {Value(err_code())};
171 write_wasm_stat(stack, stat_buf, st);
172 return {Value(i32_t(0))};
173 } catch(...) {
174 return {Value(i32_t(-EFAULT))};
175 }
176}
177
178// fstat(fd:i32, stat_buf) -> i32
179static std::vector<Value> fs_fstat(Stack& stack) {

Callers

nothing calls this directly

Calls 6

get_ptrFunction · 0.85
mem_stringFunction · 0.85
sys_statFunction · 0.85
ValueClass · 0.85
err_codeFunction · 0.85
write_wasm_statFunction · 0.85

Tested by

no test coverage detected