Fixed: Don't try to use a directory if empty

This commit is contained in:
kervala 2016-06-12 14:18:36 +02:00
parent b4696caf98
commit ee1c27ebd4
3 changed files with 23 additions and 11 deletions

View file

@ -502,6 +502,8 @@ bool CConfigFile::isRyzomInstalledIn(const QString &directory) const
bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
{ {
if (directory.isEmpty()) return false;
QDir dir(directory); QDir dir(directory);
// directory doesn't exist // directory doesn't exist
@ -528,6 +530,8 @@ bool CConfigFile::areRyzomDataInstalledIn(const QString &directory) const
bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
{ {
if (directory.isEmpty()) return false;
QDir dir(directory); QDir dir(directory);
// directory doesn't exist // directory doesn't exist
@ -557,6 +561,8 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
bool CConfigFile::foundTemporaryFiles(const QString &directory) const bool CConfigFile::foundTemporaryFiles(const QString &directory) const
{ {
if (directory.isEmpty()) return false;
QDir dir(directory); QDir dir(directory);
// directory doesn't exist // directory doesn't exist

View file

@ -52,6 +52,8 @@ void CFilesCleaner::setDirectory(const QString &src)
bool CFilesCleaner::exec() bool CFilesCleaner::exec()
{ {
if (m_directory.isEmpty()) return false;
if (m_listener) m_listener->operationPrepare(); if (m_listener) m_listener->operationPrepare();
QDir dir(m_directory); QDir dir(m_directory);

View file

@ -37,23 +37,27 @@ QString qBytesToHumanReadable(qint64 bytes)
qint64 getDirectorySize(const QString &directory) qint64 getDirectorySize(const QString &directory)
{ {
qint64 size = 0; 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()); QFileInfo fileInfo = list.at(i);
}
else if (fileInfo.isDir())
{ {
size += fileInfo.size(); size += getDirectorySize(fileInfo.absoluteFilePath());
}
else
{
size += fileInfo.size();
}
} }
} }
} }