From 68041e382d9874e5bcb610d232e2257c653893e0 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 15 Feb 2012 21:57:40 +0200 Subject: [PATCH] Clean up misc::isValidFileSystemName() function --- src/misc.cpp | 9 +++------ src/misc.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index d411a9ac6..70dbbab67 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -575,13 +575,10 @@ QString misc::toValidFileSystemName(QString filename) { return filename; } -bool misc::isValidFileSystemName(QString filename) { - filename.replace("\\", "/").trimmed(); +bool misc::isValidFileSystemName(const QString& filename) { if(filename.isEmpty()) return false; - const QRegExp regex("[/:?\"*<>|]"); - if(filename.contains(regex)) - return false; - return true; + const QRegExp regex("[\\\\/:?\"*<>|]"); + return !filename.contains(regex); } #ifndef DISABLE_GUI diff --git a/src/misc.h b/src/misc.h index 4cce42d8f..6a75da85f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -140,7 +140,7 @@ public: static bool isUrl(const QString &s); static void copyDir(QString src_path, QString dst_path); static QString toValidFileSystemName(QString filename); - static bool isValidFileSystemName(QString filename); + static bool isValidFileSystemName(const QString& filename); /* Ported from Qt4 to drop dependency on QtGui */ static QString QDesktopServicesDataLocation();