Deduces project_root for dyn modules. First attempt: from command line arguments Second try: project file Third try: path from compiled file Default: empty
| 387 | // Third try: path from compiled file |
| 388 | // Default: empty |
| 389 | static 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 | |
| 415 | void replace( string& str, const string& from, const string& to ) { |
| 416 | size_t it = str.find(from); |
no test coverage detected