MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / sanitizeFilename

Function sanitizeFilename

src/Engine/CrossPlatform.cpp:683–700  ·  view source on GitHub ↗

* Replaces invalid filesystem characters with _. * @param filename Original filename. * @return Filename without invalid characters */

Source from the content-addressed store, hash-verified

681 * @return Filename without invalid characters
682 */
683std::string sanitizeFilename(const std::string &filename)
684{
685 std::string newFilename = filename;
686 for (std::string::iterator i = newFilename.begin(); i != newFilename.end(); ++i)
687 {
688 if ((*i) == '<' ||
689 (*i) == '>' ||
690 (*i) == ':' ||
691 (*i) == '"' ||
692 (*i) == '/' ||
693 (*i) == '?' ||
694 (*i) == '\\')
695 {
696 *i = '_';
697 }
698 }
699 return newFilename;
700}
701
702/**
703 * Removes the extension from a filename.

Callers 5

quitMethod · 0.85
saveGameMethod · 0.85
SaveGameStateMethod · 0.85
DefeatStateMethod · 0.85
VictoryStateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected