Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. bool RemoveDirectory(QDir &aDir)
  2. {
  3. bool has_err = false;
  4. if (aDir.exists())//QDir::NoDotAndDotDot
  5. {
  6. QFileInfoList entries = aDir.entryInfoList(QDir::NoDotAndDotDot |
  7. QDir::Dirs | QDir::Files);
  8. int count = entries.size();
  9. for (int idx = 0; ((idx < count) && (RBCFS_OK == has_err)); idx++)
  10. {
  11. QFileInfo entryInfo = entries[idx];
  12. QString path = entryInfo.absoluteFilePath();
  13. if (entryInfo.isDir())
  14. {
  15. has_err = RemoveDirectory(QDir(path));
  16. }
  17. else
  18. {
  19. QFile file(path);
  20. if (!file.remove())
  21. has_err = true;
  22. }
  23. }
  24. if (!aDir.rmdir(aDir.absolutePath()))
  25. has_err = true;
  26. }
  27. return(has_err);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement