1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

avoid forbidden chars in path

This commit is contained in:
Michael 2023-08-23 22:23:05 +02:00 committed by GitHub
parent b22a9ff2d0
commit 485af4b4b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -212,7 +212,11 @@ void CPlayerInterface::performAutosave()
prefix = settings["general"]["savePrefix"].String();
if(prefix.empty())
{
prefix = cb->getMapHeader()->name.substr(0, 15) + "_" + cb->getStartInfo()->startTimeIso8601 + "/";
std::string name = cb->getMapHeader()->name.substr(0, 15);
std::string forbiddenChars("\\/:?\"<>| ");
std::replace_if(name.begin(), name.end(), [&](char c) { return std::string::npos != forbiddenChars.find(c); }, '_' );
prefix = name + "_" + cb->getStartInfo()->startTimeIso8601 + "/";
}
}

View File

@ -19,7 +19,6 @@ namespace vstd
{
std::tm tm = *std::localtime(&dt);
std::stringstream s;
s.imbue(std::locale(""));
s << std::put_time(&tm, "%Y%m%dT%H%M%S");
return s.str();
}