| 214 | } |
| 215 | |
| 216 | void ClientContext::addDBDirToFileSearchPath(const std::string& dbPath) { |
| 217 | // Skip remote paths (e.g. s3://, https://) |
| 218 | if (dbPath.find("://") != std::string::npos) { |
| 219 | return; |
| 220 | } |
| 221 | if (dbPath.find_first_of("/\\") == std::string::npos) { |
| 222 | return; |
| 223 | } |
| 224 | const auto expandedPath = storage::StorageUtils::expandPath(this, dbPath); |
| 225 | const auto slashPos = expandedPath.find_last_of("/\\"); |
| 226 | if (slashPos == std::string::npos) { |
| 227 | return; |
| 228 | } |
| 229 | std::string dirPath = expandedPath.substr(0, slashPos); |
| 230 | if (dirPath.empty()) { |
| 231 | dirPath = expandedPath[slashPos] == '\\' ? "\\" : "/"; |
| 232 | } else { |
| 233 | dirPath = std::filesystem::absolute(dirPath).lexically_normal().string(); |
| 234 | } |
| 235 | // Prepend to fileSearchPath if not already present |
| 236 | auto& fileSearchPath = clientConfig.fileSearchPath; |
| 237 | if (!fileSearchPath.empty()) { |
| 238 | const auto searchPaths = StringUtils::split(fileSearchPath, ","); |
| 239 | if (std::find(searchPaths.begin(), searchPaths.end(), dirPath) != searchPaths.end()) { |
| 240 | return; |
| 241 | } |
| 242 | fileSearchPath = std::format("{},{}", dirPath, fileSearchPath); |
| 243 | } else { |
| 244 | fileSearchPath = dirPath; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | std::string ClientContext::getEnvVariable(const std::string& name) { |
| 249 | #if defined(_WIN32) |