MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / cliFindScriptInRoot

Function cliFindScriptInRoot

Source/Basic/Application.cpp:457–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455}
456
457std::optional<fs::path> cliFindScriptInRoot(const fs::path& root) {
458 std::error_code err;
459 auto base = fs::weakly_canonical(root, err);
460 if (err) base = root;
461 if (!fs::is_directory(base, err)) return std::nullopt;
462 for (const auto& candidate : {base / "Script" / "Dev" / "cli.lua", base / "cli.lua"}) {
463 if (fs::is_regular_file(candidate, err)) {
464 return fs::weakly_canonical(candidate, err);
465 }
466 err.clear();
467 }
468 for (auto it = fs::recursive_directory_iterator(base, fs::directory_options::skip_permission_denied, err); it != fs::recursive_directory_iterator(); it.increment(err)) {
469 if (err) {
470 err.clear();
471 continue;
472 }
473 const auto& entry = *it;
474 if (entry.is_directory(err)) {
475 if (cliSkipEntrySearchDir(entry.path())) {
476 it.disable_recursion_pending();
477 }
478 continue;
479 }
480 if (entry.is_regular_file(err) && entry.path().filename() == "cli.lua") {
481 return fs::weakly_canonical(entry.path(), err);
482 }
483 }
484 return std::nullopt;
485}
486
487std::optional<fs::path> cliFindScript(int argc, char* argv[], const std::optional<fs::path>& assetPath) {
488 if (auto script = std::getenv("DORA_CLI_SCRIPT")) {

Callers 1

cliFindScriptFunction · 0.85

Calls 11

weakly_canonicalFunction · 0.85
is_directoryFunction · 0.85
is_regular_fileFunction · 0.85
cliSkipEntrySearchDirFunction · 0.85
incrementMethod · 0.80
is_directoryMethod · 0.80
is_regular_fileMethod · 0.80
clearMethod · 0.65
pathMethod · 0.45
filenameMethod · 0.45

Tested by

no test coverage detected