Directory.hxx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
  3. #ifndef cmsys_Directory_hxx
  4. #define cmsys_Directory_hxx
  5. #include <cmsys/Configure.h>
  6. #include <string>
  7. namespace cmsys {
  8. class DirectoryInternals;
  9. /** \class Directory
  10. * \brief Portable directory/filename traversal.
  11. *
  12. * Directory provides a portable way of finding the names of the files
  13. * in a system directory.
  14. *
  15. * Directory currently works with Windows and Unix operating systems.
  16. */
  17. class cmsys_EXPORT Directory
  18. {
  19. public:
  20. Directory();
  21. ~Directory();
  22. /**
  23. * Load the specified directory and load the names of the files
  24. * in that directory. 0 is returned if the directory can not be
  25. * opened, 1 if it is opened.
  26. */
  27. bool Load(const std::string&);
  28. /**
  29. * Return the number of files in the current directory.
  30. */
  31. unsigned long GetNumberOfFiles() const;
  32. /**
  33. * Return the number of files in the specified directory.
  34. * A higher performance static method.
  35. */
  36. static unsigned long GetNumberOfFilesInDirectory(const std::string&);
  37. /**
  38. * Return the file at the given index, the indexing is 0 based
  39. */
  40. const char* GetFile(unsigned long) const;
  41. /**
  42. * Return the path to Open'ed directory
  43. */
  44. const char* GetPath() const;
  45. /**
  46. * Clear the internal structure. Used internally at beginning of Load(...)
  47. * to clear the cache.
  48. */
  49. void Clear();
  50. private:
  51. // Private implementation details.
  52. DirectoryInternals* Internal;
  53. Directory(const Directory&); // Not implemented.
  54. void operator=(const Directory&); // Not implemented.
  55. }; // End Class: Directory
  56. } // namespace cmsys
  57. #endif