MCPcopy Create free account
hub / github.com/covscript/covscript / prepend_import_path

Function prepend_import_path

sources/covscript.cpp:307–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305 }
306
307 void prepend_import_path(const std::string &script, cs::process_context *context)
308 {
309 if (script.empty()) {
310 return;
311 }
312
313 if (cs_impl::file_system::is_absolute_path(script)) {
314 // If it's absolute path
315 auto pos = script.find_last_of(cs::path_separator);
316
317 // in case of: /main.csc
318 if (pos > 0) {
319 context->import_path = script.substr(0, pos) + cs::path_delimiter + context->import_path;
320 }
321 else {
322 context->import_path = std::to_string(cs::path_separator) + cs::path_delimiter + context->import_path;
323 }
324 }
325 else {
326 // If it's relative path
327 prepend_import_path(cs_impl::file_system::get_current_dir() + cs::path_separator + script, context);
328 }
329 }
330
331 array parse_cmd_args(int argc, char *argv[])
332 {

Callers 2

covscript_mainFunction · 0.85
covscript_mainFunction · 0.85

Calls 4

is_absolute_pathFunction · 0.85
get_current_dirFunction · 0.85
to_stringFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected