summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/FileUtil.cpp15
-rw-r--r--Source/Core/Common/FileUtil.h4
2 files changed, 18 insertions, 1 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index e761f3ade1..acf154f81a 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -5,6 +5,7 @@
#include <algorithm>
#include <cstddef>
#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <limits.h>
@@ -30,7 +31,6 @@
#include <dirent.h>
#include <errno.h>
#include <libgen.h>
-#include <stdlib.h>
#include <unistd.h>
#endif
@@ -712,6 +712,19 @@ std::string GetBundleDirectory()
}
#endif
+std::string GetAbsolutePath(const std::string& path)
+{
+#ifdef _WIN32
+ wchar_t absolute_path[_MAX_PATH];
+ wchar_t* result = _wfullpath(absolute_path, UTF8ToTStr(path).c_str(), _MAX_PATH);
+ return result ? TStrToUTF8(result) : "";
+#else
+ char absolute_path[MAX_PATH + 1];
+ char* result = realpath(path.c_str(), absolute_path);
+ return result ? result : "";
+#endif
+}
+
std::string& GetExeDirectory()
{
static std::string DolphinPath;
diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h
index f4a20f623d..cc0ec5a651 100644
--- a/Source/Core/Common/FileUtil.h
+++ b/Source/Core/Common/FileUtil.h
@@ -133,6 +133,10 @@ std::string CreateTempDir();
// Get a filename that can hopefully be atomically renamed to the given path.
std::string GetTempFilenameForAtomicWrite(const std::string& path);
+// Converts the given path into an absolute path.
+// An empty string is returned if an error occurs.
+std::string GetAbsolutePath(const std::string& path);
+
// Gets a set user directory path
// Don't call prior to setting the base user directory
const std::string& GetUserPath(unsigned int dir_index);