System: Improve screenshot naming

This commit is contained in:
Stenzek
2024-03-15 15:21:06 +10:00
parent 6aa491f863
commit 43eb6e20fa
5 changed files with 50 additions and 10 deletions

View File

@ -182,6 +182,25 @@ void Path::SanitizeFileName(std::string* str, bool strip_slashes /* = true */)
#endif
}
std::string Path::RemoveLengthLimits(std::string_view str)
{
std::string ret;
#ifdef _WIN32
ret.reserve(str.length() + 4);
#endif
ret.append(str);
RemoveLengthLimits(&ret);
return ret;
}
void Path::RemoveLengthLimits(std::string* path)
{
DebugAssert(IsAbsolute(*path));
#ifdef _WIN32
path->insert(0, "\\\\?\\");
#endif
}
bool Path::IsAbsolute(const std::string_view& path)
{
#ifdef _WIN32

View File

@ -28,6 +28,10 @@ void Canonicalize(std::string* path);
std::string SanitizeFileName(const std::string_view& str, bool strip_slashes = true);
void SanitizeFileName(std::string* str, bool strip_slashes = true);
/// Mutates the path to remove any MAX_PATH limits (for Windows).
std::string RemoveLengthLimits(std::string_view str);
void RemoveLengthLimits(std::string* path);
/// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix).
bool IsAbsolute(const std::string_view& path);