mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Move removeDirectory to TomahawkUtils
This commit is contained in:
@@ -550,30 +550,5 @@ AtticaManager::doResolverRemove( const QString& id ) const
|
|||||||
!resolverDir.absolutePath().contains( id ) )
|
!resolverDir.absolutePath().contains( id ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
removeDirectory( resolverDir.absolutePath() );
|
TomahawkUtils::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;
|
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,6 @@ public:
|
|||||||
virtual ~AtticaManager() {}
|
virtual ~AtticaManager() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool removeDirectory( const QString& dir );
|
|
||||||
#ifdef LIBATTICA_FOUND
|
#ifdef LIBATTICA_FOUND
|
||||||
|
|
||||||
bool resolversLoaded() const;
|
bool resolversLoaded() const;
|
||||||
|
@@ -218,7 +218,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
setAllScriptResolvers( listedResolvers );
|
setAllScriptResolvers( listedResolvers );
|
||||||
setEnabledScriptResolvers( enabledResolvers );
|
setEnabledScriptResolvers( enabledResolvers );
|
||||||
tDebug() << "UPGRADING AND DELETING:" << resolverDir.absolutePath();
|
tDebug() << "UPGRADING AND DELETING:" << resolverDir.absolutePath();
|
||||||
AtticaManager::removeDirectory( resolverDir.absolutePath() );
|
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -665,5 +665,29 @@ setHeaderHeight( int height )
|
|||||||
s_headerHeight = 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
|
} // ns
|
||||||
|
@@ -104,6 +104,8 @@ namespace TomahawkUtils
|
|||||||
|
|
||||||
DLLEXPORT int headerHeight();
|
DLLEXPORT int headerHeight();
|
||||||
DLLEXPORT void setHeaderHeight( int height );
|
DLLEXPORT void setHeaderHeight( int height );
|
||||||
|
|
||||||
|
DLLEXPORT bool removeDirectory( const QString& dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOMAHAWKUTILS_H
|
#endif // TOMAHAWKUTILS_H
|
||||||
|
Reference in New Issue
Block a user