Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Folder.h 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*!
  2. * \file include/utils/FileSystem.h
  3. * \brief Recursive file-system walking utilities
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _UTILS_FOLDER_H_
  8. #define _UTILS_FOLDER_H_
  9. #include "Exception.h"
  10. #include "utils/File.h"
  11. #include <functional>
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. class Folder {
  16. public:
  17. Folder(std::string folder, bool listDotFiles = false);
  18. std::string &getName();
  19. std::string &getPath();
  20. unsigned long fileCount();
  21. File &getFile(unsigned long i);
  22. unsigned long folderCount();
  23. Folder &getFolder(unsigned long i);
  24. Folder getParent();
  25. void executeRemoveFiles(std::function<bool (File &f)> func);
  26. // Accessing a folder recursively
  27. // This treats all files in all subfolders as if they were in this folder
  28. unsigned long countRecursiveFiles();
  29. void executeRemoveRecursiveFiles(std::function<bool (File &f)> func);
  30. std::string getRecursiveFileName(unsigned long i);
  31. File &getRecursiveFile(unsigned long i);
  32. private:
  33. void createFolderItems();
  34. int readFolderItems(std::vector<std::string> &foundFiles, std::vector<std::string> &foundFolders);
  35. std::string name; //!< Only last part of path
  36. std::string path; //!< Full path, with name and '/' at end
  37. bool hasListed;
  38. bool listDot;
  39. std::vector<File> files;
  40. std::vector<Folder> folders;
  41. };
  42. #endif