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

Method resolve

src/exec/ModuleQueue.cpp:92–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92std::filesystem::path ModuleQueue::resolve(std::string module_name, std::filesystem::path parent){
93 // Exact match
94 if(std::filesystem::exists(module_name)){
95 return module_name;
96 }
97 // ./ and ../
98 if(module_name.starts_with("./") || module_name.starts_with("../")){
99 auto extended_path = extend(parent / module_name);
100 if(extended_path){
101 return extended_path.value();
102 }
103 throw Exception::Exception(std::string("module '") + module_name + "' not found");
104 }
105 // extra_paths
106 for(std::filesystem::path extra_path : extra_paths){
107 auto extended_path = extend(extra_path / module_name);
108 if(extended_path){
109 return extended_path.value();
110 }
111 }
112 // current_paths
113 if(check_parent){
114 auto extended_path = extend(parent / module_name);
115 if(extended_path){
116 return extended_path.value();
117 }
118 }
119 // system_paths
120 if(system_path){
121 auto extended_path = extend(system_path.value() / module_name);
122 if(extended_path){
123 return extended_path.value();
124 }
125 }
126 throw Exception::Exception(std::string("module '") + module_name + "' not found");
127}

Callers

nothing calls this directly

Calls 3

extendFunction · 0.85
ExceptionClass · 0.85
starts_withMethod · 0.80

Tested by

no test coverage detected