Implement Advanced Saving Management subsystem

Closes #4696
This commit is contained in:
Vladimir Golovnev (Glassez) 2016-02-09 11:56:48 +03:00 committed by sledgehammer999
commit 3d107e0588
59 changed files with 1792 additions and 1276 deletions

View file

@ -250,22 +250,23 @@ bool Utils::Fs::sameFiles(const QString& path1, const QString& path2)
return same;
}
QString Utils::Fs::toValidFileSystemName(const QString &filename)
QString Utils::Fs::toValidFileSystemName(const QString &name, bool allowSeparators)
{
static const QRegExp regex("[\\\\/:?\"*<>|]");
QRegExp regex(allowSeparators ? "[:?\"*<>|]+" : "[\\\\/:?\"*<>|]+");
QString validName = filename.trimmed();
QString validName = name.trimmed();
validName.replace(regex, " ");
qDebug() << "toValidFileSystemName:" << filename << "=>" << validName;
qDebug() << "toValidFileSystemName:" << name << "=>" << validName;
return validName;
}
bool Utils::Fs::isValidFileSystemName(const QString& filename)
bool Utils::Fs::isValidFileSystemName(const QString &name, bool allowSeparators)
{
if (filename.isEmpty()) return false;
const QRegExp regex("[\\\\/:?\"*<>|]");
return !filename.contains(regex);
if (name.isEmpty()) return false;
QRegExp regex(allowSeparators ? "[:?\"*<>|]" : "[\\\\/:?\"*<>|]");
return !name.contains(regex);
}
qlonglong Utils::Fs::freeDiskSpaceOnPath(QString path)

View file

@ -48,8 +48,8 @@ namespace Utils
QString folderName(const QString& file_path);
qint64 computePathSize(const QString& path);
bool sameFiles(const QString& path1, const QString& path2);
QString toValidFileSystemName(const QString &filename);
bool isValidFileSystemName(const QString& filename);
QString toValidFileSystemName(const QString &name, bool allowSeparators = false);
bool isValidFileSystemName(const QString& name, bool allowSeparators = false);
qlonglong freeDiskSpaceOnPath(QString path);
QString branchPath(const QString& file_path, QString* removed = 0);
bool sameFileNames(const QString& first, const QString& second);

View file

@ -39,6 +39,7 @@
#include <QFile>
#include <QDir>
#include <QUrl>
#include <QSize>
#include "base/types.h"
/* Miscellaneous functions that can be useful */