Code police and simplify function a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15089 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
79d358baca
commit
abd8c39a4d
1 changed files with 16 additions and 17 deletions
|
@ -24,22 +24,21 @@
|
|||
// recursive function to delete a dir with files
|
||||
bool recRmdir( const QString &dirName )
|
||||
{
|
||||
QString dirN = dirName;
|
||||
QDir dir(dirN);
|
||||
QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
|
||||
QFileInfo fileInfo;
|
||||
QString curItem, lstAt;
|
||||
for(int i = 0; i < list.size(); i++){ // loop through all items of list
|
||||
QString name = list.at(i);
|
||||
if(!(name == ".") && !(name == "..")){
|
||||
curItem = dirN + "/" + name;
|
||||
fileInfo.setFile(curItem);
|
||||
if(fileInfo.isDir()) // is directory
|
||||
recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
|
||||
else // is file
|
||||
QFile::remove(curItem); // ok, delete file
|
||||
QString dirN = dirName;
|
||||
QDir dir(dirN);
|
||||
// make list of entries in directory
|
||||
QStringList list = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
|
||||
QFileInfo fileInfo;
|
||||
QString curItem, lstAt;
|
||||
for(int i = 0; i < list.size(); i++){ // loop through all items of list
|
||||
QString name = list.at(i);
|
||||
curItem = dirN + "/" + name;
|
||||
fileInfo.setFile(curItem);
|
||||
if(fileInfo.isDir()) // is directory
|
||||
recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
|
||||
else // is file
|
||||
QFile::remove(curItem); // ok, delete file
|
||||
}
|
||||
}
|
||||
dir.cdUp();
|
||||
return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
|
||||
dir.cdUp();
|
||||
return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue