MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / deduce_project_root

Function deduce_project_root

utils/daScript/main.cpp:389–413  ·  view source on GitHub ↗

Deduces project_root for dyn modules. First attempt: from command line arguments Second try: project file Third try: path from compiled file Default: empty

Source from the content-addressed store, hash-verified

387// Third try: path from compiled file
388// Default: empty
389static string deduce_project_root(string maybe_project_root, string compile_file) {
390 if (!maybe_project_root.empty()) {
391 return maybe_project_root;
392 }
393 if (!projectFile.empty()) {
394 auto access = get_file_access((char*)(projectFile.empty() ? nullptr : projectFile.c_str()));
395 auto maybe_result = access->getDynModulesFolder();
396 if (!maybe_result.empty()) {
397 return maybe_result;
398 }
399 }
400 if (!compile_file.empty()) {
401 auto filename_start = compile_file.find_last_of("\\/");
402 string project_root;
403 if (filename_start != string::npos) {
404 // Try from directory where first script located
405 project_root = compile_file.substr(0, filename_start);
406 } else {
407 // Try from current directory.
408 project_root = "./";
409 }
410 return project_root;
411 }
412 return "";
413}
414
415void replace( string& str, const string& from, const string& to ) {
416 size_t it = str.find(from);

Callers 1

MAIN_FUNC_NAMEFunction · 0.85

Calls 3

getDynModulesFolderMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected