Hi,

This might help someone, tested on Ubuntu 9.04 -

Qt Code:
  1. bool LocalCaseList::removeDirectory(QDir &directory)
  2. {
  3. bool isSuccessful = true;
  4.  
  5. if (directory.exists())
  6. {
  7. QFileInfoList entries = directory.entryInfoList(QDir::NoDotAndDotDot | QDir::Hidden | QDir::Dirs | QDir::Files);
  8. int count = entries.size();
  9.  
  10. for (int i = 0; ((i < count) && (isSuccessful == true)); i++)
  11. {
  12. QFileInfo entryInfo = entries[i];
  13. QString path = entryInfo.absoluteFilePath();
  14. if (entryInfo.isDir())
  15. {
  16. QDir innerDirectory = QDir(path);
  17. isSuccessful = removeDirectory(innerDirectory);
  18. }
  19. else
  20. {
  21. QFile file(path);
  22. if (!file.remove())
  23. isSuccessful = false;
  24. }
  25. }
  26. if (!directory.rmdir(directory.absolutePath()))
  27. isSuccessful = false;
  28. }
  29.  
  30. return(isSuccessful);
  31. }
To copy to clipboard, switch view to plain text mode