MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / addInitFileDirToSearchPath

Function addInitFileDirToSearchPath

tools/shell/shell_runner.cpp:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void addInitFileDirToSearchPath(const std::shared_ptr<Connection>& conn,
30 const std::string& initFile) {
31 auto slashPos = initFile.find_last_of('/');
32 if (slashPos == std::string::npos) {
33 return;
34 }
35 auto initDirPath = initFile.substr(0, slashPos);
36 if (initDirPath.empty()) {
37 initDirPath = "/";
38 } else if (initFile.find("://") == std::string::npos) {
39 initDirPath = std::filesystem::absolute(initDirPath).lexically_normal().string();
40 }
41 auto clientConfig = conn->getClientContext()->getClientConfigUnsafe();
42 auto& fileSearchPath = clientConfig->fileSearchPath;
43 if (!fileSearchPath.empty()) {
44 auto searchPaths = StringUtils::split(fileSearchPath, ",");
45 if (std::find(searchPaths.begin(), searchPaths.end(), initDirPath) != searchPaths.end()) {
46 return;
47 }
48 fileSearchPath = std::format("{},{}", initDirPath, fileSearchPath);
49 return;
50 }
51 fileSearchPath = initDirPath;
52}
53
54void processRunCommands(EmbeddedShell& shell, const std::shared_ptr<Connection>& conn,
55 const std::string& filename) {

Callers 1

mainFunction · 0.85

Calls 5

emptyMethod · 0.45
findMethod · 0.45
getClientContextMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected