summaryrefslogtreecommitdiff
path: root/Source/Core/Common/FileUtil.cpp
diff options
context:
space:
mode:
authorSilent <zdanio95@gmail.com>2019-10-06 21:37:51 +0200
committerSilent <zdanio95@gmail.com>2019-10-07 22:45:16 +0200
commit3b21d328653f7a472b0f77ef1cc0c85766566b96 (patch)
treeb6e6595dc7edf1021a4cbade51ecdf3cd23bffda /Source/Core/Common/FileUtil.cpp
parentb6545ea285b25765bbf464774f9a8e7649f6bc15 (diff)
Remove MAX_PATH limit from:
- GetTempFilenameForAtomicWrite - SetUserDirectory
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
-rw-r--r--Source/Core/Common/FileUtil.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 75118bffac..814d891c22 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -639,19 +639,21 @@ std::string CreateTempDir()
#endif
}
-std::string GetTempFilenameForAtomicWrite(const std::string& path)
+std::string GetTempFilenameForAtomicWrite(std::string path)
{
- std::string abs = path;
#ifdef _WIN32
- TCHAR absbuf[MAX_PATH];
- if (_tfullpath(absbuf, UTF8ToTStr(path).c_str(), MAX_PATH) != nullptr)
- abs = TStrToUTF8(absbuf);
+ std::unique_ptr<TCHAR[], decltype(&std::free)> absbuf{
+ _tfullpath(nullptr, UTF8ToTStr(path).c_str(), 0), std::free};
+ if (absbuf != nullptr)
+ {
+ path = TStrToUTF8(absbuf.get());
+ }
#else
char absbuf[PATH_MAX];
if (realpath(path.c_str(), absbuf) != nullptr)
- abs = absbuf;
+ path = absbuf;
#endif
- return abs + ".xxx";
+ return std::move(path) + ".xxx";
}
#if defined(__APPLE__)