From 3b21d328653f7a472b0f77ef1cc0c85766566b96 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 6 Oct 2019 21:37:51 +0200 Subject: Remove MAX_PATH limit from: - GetTempFilenameForAtomicWrite - SetUserDirectory --- Source/Core/Common/FileUtil.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'Source/Core/Common/FileUtil.cpp') 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 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__) -- cgit v1.2.3