diff --git a/MantidPlot/src/ProjectRecovery.cpp b/MantidPlot/src/ProjectRecovery.cpp index e8e689eeb220f0ab8aa243258240ace1b1ee7027..98c664ea88e61abbaae8c4a03034c9f22a10d25c 100644 --- a/MantidPlot/src/ProjectRecovery.cpp +++ b/MantidPlot/src/ProjectRecovery.cpp @@ -11,7 +11,9 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/UsageService.h" +#include "boost/algorithm/string/classification.hpp" #include "boost/optional.hpp" +#include "boost/range/algorithm_ext/erase.hpp" #include "Poco/DirectoryIterator.h" #include "Poco/NObserver.h" @@ -132,6 +134,13 @@ getRecoveryFolderCheckpoints(const std::string &recoveryFolderPath) { return folderPaths; } +std::string removeInvalidFilenameChars(std::string s) { + // NTFS is most restrictive, so blacklist on this + std::string blacklistChars{":*?<>|/\"\\"}; + boost::remove_erase_if(s, boost::is_any_of(blacklistChars)); + return s; +} + const std::string OUTPUT_PROJ_NAME = "recovery.mantid"; // Config keys @@ -437,7 +446,7 @@ void ProjectRecovery::saveWsHistories(const Poco::Path &historyDestFolder) { alg->setLogging(false); for (const auto &ws : wsHandles) { - std::string filename = ws->getName(); + std::string filename = removeInvalidFilenameChars(ws->getName()); filename.append(".py"); Poco::Path destFilename = historyDestFolder;