Remove MAX_PATH limit from:

- GetTempFilenameForAtomicWrite
- SetUserDirectory
This commit is contained in:
Silent
2019-10-06 21:37:51 +02:00
parent b6545ea285
commit 3b21d32865
3 changed files with 36 additions and 23 deletions

View File

@ -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__)