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

Method setPath

lib/loader/filemgr.cpp:14–38  ·  view source on GitHub ↗

Set path to file manager. See "include/loader/filemgr.h".

Source from the content-addressed store, hash-verified

12
13// Set path to file manager. See "include/loader/filemgr.h".
14Expect<void> FileMgr::setPath(const std::filesystem::path &FilePath) {
15 reset();
16 std::error_code ErrCode;
17 Size = std::filesystem::file_size(FilePath, ErrCode);
18 if (likely(!ErrCode)) {
19 if (!MMap::supported()) {
20 Size = 0;
21 Status = ErrCode::Value::IllegalPath;
22 return Unexpect(Status);
23 }
24 FileMap.emplace(FilePath);
25 if (auto *Pointer = FileMap->address(); likely(Pointer)) {
26 Data = reinterpret_cast<const Byte *>(Pointer);
27 Status = ErrCode::Value::Success;
28 } else {
29 // File size is 0, mmap failed.
30 // Will get 'UnexpectedEnd' error while the first reading.
31 FileMap.reset();
32 }
33 return {};
34 }
35 Size = 0;
36 Status = ErrCode::Value::IllegalPath;
37 return Unexpect(Status);
38}
39
40// Set code data. See "include/loader/filemgr.h".
41Expect<void> FileMgr::setCode(Span<const Byte> CodeData) {

Callers 2

parseWasmUnitMethod · 0.80
TESTFunction · 0.80

Calls 6

resetFunction · 0.85
UnexpectFunction · 0.85
addressMethod · 0.80
likelyFunction · 0.50
emplaceMethod · 0.45
resetMethod · 0.45

Tested by 1

TESTFunction · 0.64