Fix getAbsolutePath (use POSIX realpath)

pull/11/head
Ibrahim Numanagić 2022-02-25 09:19:35 -08:00
parent 56cd0711f7
commit 4bfab60ac6
2 changed files with 7 additions and 4 deletions

View File

@ -247,9 +247,12 @@ ImportFile getRoot(const std::string argv0, const std::vector<std::string> &plug
} // namespace } // namespace
std::string getAbsolutePath(const std::string &path) { std::string getAbsolutePath(const std::string &path) {
llvm::SmallString<128> p(path); char *c = realpath(path.c_str(), nullptr);
llvm::sys::fs::make_absolute(p); if (!c)
return std::string(p); return path;
std::string result(c);
free(c);
return result;
} }
std::shared_ptr<ImportFile> getImportFile(const std::string &argv0, std::shared_ptr<ImportFile> getImportFile(const std::string &argv0,

View File

@ -167,7 +167,7 @@ template <typename T> std::vector<T> clone_nop(const std::vector<T> &t) {
/// Path utilities /// Path utilities
/// @return The absolute path of a given path. /// @return The absolute canonical path of a given path.
std::string getAbsolutePath(const std::string &path); std::string getAbsolutePath(const std::string &path);
/// Detect a absolute path of the current executable (whose argv0 is known). /// Detect a absolute path of the current executable (whose argv0 is known).