1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

Move removeDirectory to TomahawkUtils

This commit is contained in:
Leo Franchi 2011-10-19 19:45:39 -04:00
parent 378aae9567
commit 24c7b0074a
5 changed files with 28 additions and 28 deletions

View File

@ -550,30 +550,5 @@ AtticaManager::doResolverRemove( const QString& id ) const
!resolverDir.absolutePath().contains( id ) )
return;
removeDirectory( resolverDir.absolutePath() );
}
// taken from util/fileutils.cpp in kdevplatform
bool
AtticaManager::removeDirectory( const QString& dir )
{
const QDir aDir(dir);
tLog() << "Deleting DIR:" << dir;
bool has_err = false;
if (aDir.exists()) {
foreach(const QFileInfo& entry, aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::NoSymLinks)) {
QString path = entry.absoluteFilePath();
if (entry.isDir()) {
has_err = !removeDirectory(path) || has_err;
} else if (!QFile::remove(path)) {
has_err = true;
}
}
if (!aDir.rmdir(aDir.absolutePath())) {
has_err = true;
}
}
return !has_err;
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
}

View File

@ -75,7 +75,6 @@ public:
virtual ~AtticaManager() {}
#endif
static bool removeDirectory( const QString& dir );
#ifdef LIBATTICA_FOUND
bool resolversLoaded() const;

View File

@ -218,7 +218,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
setAllScriptResolvers( listedResolvers );
setEnabledScriptResolvers( enabledResolvers );
tDebug() << "UPGRADING AND DELETING:" << resolverDir.absolutePath();
AtticaManager::removeDirectory( resolverDir.absolutePath() );
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
}
}
}

View File

@ -665,5 +665,29 @@ setHeaderHeight( int height )
s_headerHeight = height;
}
// taken from util/fileutils.cpp in kdevplatform
bool
removeDirectory( const QString& dir )
{
const QDir aDir(dir);
tLog() << "Deleting DIR:" << dir;
bool has_err = false;
if (aDir.exists()) {
foreach(const QFileInfo& entry, aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::NoSymLinks)) {
QString path = entry.absoluteFilePath();
if (entry.isDir()) {
has_err = !removeDirectory(path) || has_err;
} else if (!QFile::remove(path)) {
has_err = true;
}
}
if (!aDir.rmdir(aDir.absolutePath())) {
has_err = true;
}
}
return !has_err;
}
} // ns

View File

@ -104,6 +104,8 @@ namespace TomahawkUtils
DLLEXPORT int headerHeight();
DLLEXPORT void setHeaderHeight( int height );
DLLEXPORT bool removeDirectory( const QString& dir );
}
#endif // TOMAHAWKUTILS_H