diff options
Diffstat (limited to 'src/filesys.cpp')
-rw-r--r-- | src/filesys.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/filesys.cpp b/src/filesys.cpp index 4a4a2e418..9aeecf427 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -662,6 +662,19 @@ std::string RemoveRelativePathComponents(std::string path) return path.substr(0, pos); } +std::string AbsolutePath(const std::string &path) +{ +#ifdef _WIN32 + char *abs_path = _fullpath(NULL, path.c_str(), MAX_PATH); +#else + char *abs_path = realpath(path.c_str(), NULL); +#endif + if (!abs_path) return ""; + std::string abs_path_str(abs_path); + free(abs_path); + return abs_path_str; +} + const char *GetFilenameFromPath(const char *path) { const char *filename = strrchr(path, DIR_DELIM_CHAR); |