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
std::string getAbsolutePath(const std::string &path) {
llvm::SmallString<128> p(path);
llvm::sys::fs::make_absolute(p);
return std::string(p);
char *c = realpath(path.c_str(), nullptr);
if (!c)
return path;
std::string result(c);
free(c);
return result;
}
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
/// @return The absolute path of a given path.
/// @return The absolute canonical path of a given path.
std::string getAbsolutePath(const std::string &path);
/// Detect a absolute path of the current executable (whose argv0 is known).