1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-24 14:42:53 +02:00

use existing TomahawkUtils function to remove directory

This commit is contained in:
Stefan Derkits
2014-09-10 11:01:22 +02:00
parent c910cac76c
commit 10e944b7a7
3 changed files with 2 additions and 42 deletions

View File

@@ -25,10 +25,6 @@
#include "utils/Logger.h"
#include "Source.h"
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
#include "utils/TomahawkCache.h"
#endif
#include <QDir>
#include <QSettings>
#include <QCryptographicHash>
@@ -49,7 +45,7 @@ InfoSystemCache::InfoSystemCache( QObject* parent )
if ( TomahawkSettings::instance()->infoSystemCacheVersion() < INFOSYSTEM_CACHE_VERSION )
{
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
TomahawkUtils::Cache::instance()->removeDirectoryRecursively( m_cacheBaseDir );
TomahawkUtils::removeDirectory( m_cacheBaseDir );
#else
QDir(m_cacheBaseDir)::removeRecursively();
#endif

View File

@@ -48,7 +48,7 @@ Cache::Cache()
if ( TomahawkSettings::instance()->genericCacheVersion() < CACHE_VERSION )
{
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
removeDirectoryRecursively( m_cacheBaseDir );
TomahawkUtils::removeDirectory( m_cacheBaseDir );
#else
QDir( m_cacheBaseDir )::removeRecursively();
#endif
@@ -126,33 +126,6 @@ Cache::getData( const QString& identifier, const QString& key )
}
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
bool
Cache::removeDirectoryRecursively(const QString& dirName)
{
bool result = true;
QDir dir(dirName);
if (dir.exists(dirName)) {
foreach( QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst) ) {
if (info.isDir()) {
result = removeDirectoryRecursively(info.absoluteFilePath());
}
else {
result = QFile::remove(info.absoluteFilePath());
}
if (!result) {
return result;
}
}
result = dir.rmdir(dirName);
}
return result;
}
#endif
void
Cache::putData( const QString& identifier, qint64 maxAge, const QString& key, const QVariant& value )
{

View File

@@ -81,15 +81,6 @@ public:
* @return the data, if found, if not found an invalid QVariant is returned.
*/
QVariant getData( const QString& identifier, const QString& key );
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
/**
* Recursively deletes all files & directories in a folder
* Only needed in Qt4
* @param dirName the directory which should be deleted
* @return if the removal was successfull or not
*/
bool removeDirectoryRecursively( const QString& dirName );
#endif
private slots:
void pruneTimerFired();