29 const std::string &ExprPath) {
30 namespace fs = std::filesystem;
36 if (ExprPath.empty() || ExprPath.length() > 4096) {
39 ExprPath.empty(), ExprPath.length());
46 fs::path BaseDir = fs::path(BasePath).parent_path();
47 if (BaseDir.empty()) {
53 fs::path BaseDirCanonical = fs::canonical(BaseDir, EC);
56 BaseDir.string(), EC.message());
62 fs::path ResolvedPath =
63 fs::weakly_canonical(BaseDirCanonical / ExprPath, EC);
66 (BaseDirCanonical / ExprPath).
string(), EC.message());
71 auto Status = fs::status(ResolvedPath, EC);
72 if (EC || !fs::exists(Status)) {
74 ResolvedPath.string());
79 if (fs::is_directory(Status)) {
80 ResolvedPath = ResolvedPath /
"default.nix";
81 if (!fs::exists(ResolvedPath, EC) || EC) {
82 lspserver::elog(
"path-resolve: default.nix not found in directory: {0}",
83 ResolvedPath.string());
88 lspserver::vlog(
"path-resolve: resolved to {0}", ResolvedPath.string());
89 return ResolvedPath.string();
90 }
catch (
const fs::filesystem_error &E) {