diff options
Diffstat (limited to 'src/instancemanager.cpp')
| -rw-r--r-- | src/instancemanager.cpp | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index a1b17577..e7474584 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <iplugingame.h> #include <utility.h> #include <log.h> +#include "filesystemutilities.h" #include <QCoreApplication> #include <QDir> @@ -721,7 +722,7 @@ const MOBase::IPluginGame* InstanceManager::gamePluginForDirectory( QString InstanceManager::makeUniqueName(const QString& instanceName) const { - const QString sanitized = sanitizeInstanceName(instanceName); + const QString sanitized = MOBase::sanitizeFileName(instanceName); // trying "name (N)" QString name = sanitized; @@ -742,35 +743,6 @@ bool InstanceManager::instanceExists(const QString& instanceName) const return root.exists(instanceName); } -QString InstanceManager::sanitizeInstanceName(const QString &name) const -{ - QString new_name = name; - - // Restrict the allowed characters - new_name = new_name.remove(QRegExp("[^A-Za-z0-9 _=+;!@#$%^'\\-\\.\\[\\]\\{\\}\\(\\)]")); - - // Don't end in spaces and periods - new_name = new_name.remove(QRegExp("\\.*$")); - new_name = new_name.remove(QRegExp(" *$")); - - // Recurse until stuff stops changing - if (new_name != name) { - return sanitizeInstanceName(new_name); - } - return new_name; -} - -bool InstanceManager::validInstanceName(const QString& instanceName) const -{ - if (instanceName.isEmpty()) { - return false; - } - - return (instanceName == sanitizeInstanceName(instanceName)); -} - - - std::unique_ptr<Instance> selectInstance() { auto& m = InstanceManager::singleton(); |
