From 78730c0dd4d7c36cb744ebd42eb661b2d7ce87b9 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 12 Jun 2016 14:18:36 +0200 Subject: [PATCH] Fixed: Don't try to use a directory if empty --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 6 +++++ .../ryzom_installer/src/filescleaner.cpp | 2 ++ .../client/ryzom_installer/src/utils.cpp | 26 +++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 88fae2388..8815396f7 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -502,6 +502,8 @@ bool CConfigFile::isRyzomInstalledIn(const QString &directory) const bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const { + if (directory.isEmpty()) return false; + QDir dir(directory); // directory doesn't exist @@ -528,6 +530,8 @@ bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const { + if (directory.isEmpty()) return false; + QDir dir(directory); // directory doesn't exist @@ -557,6 +561,8 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const bool CConfigFile::foundTemporaryFiles(const QString &directory) const { + if (directory.isEmpty()) return false; + QDir dir(directory); // directory doesn't exist diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp index e1481fcf9..79c42634a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescleaner.cpp @@ -52,6 +52,8 @@ void CFilesCleaner::setDirectory(const QString &src) bool CFilesCleaner::exec() { + if (m_directory.isEmpty()) return false; + if (m_listener) m_listener->operationPrepare(); QDir dir(m_directory); diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index b07db1e43..5ab73f298 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -37,23 +37,27 @@ QString qBytesToHumanReadable(qint64 bytes) qint64 getDirectorySize(const QString &directory) { qint64 size = 0; - QDir dir(directory); - if (dir.exists()) + if (!directory.isEmpty()) { - QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot); + QDir dir(directory); - for (int i = 0; i < list.size(); ++i) + if (dir.exists()) { - QFileInfo fileInfo = list.at(i); + QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot); - if (fileInfo.isDir()) + for (int i = 0; i < list.size(); ++i) { - size += getDirectorySize(fileInfo.absoluteFilePath()); - } - else - { - size += fileInfo.size(); + QFileInfo fileInfo = list.at(i); + + if (fileInfo.isDir()) + { + size += getDirectorySize(fileInfo.absoluteFilePath()); + } + else + { + size += fileInfo.size(); + } } } }