cmDirectory.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #ifndef __cmDirectory_h
  12. #define __cmDirectory_h
  13. #include <iostream>
  14. #include <string>
  15. #include <vector>
  16. /** \class cmDirectory
  17. * \brief Portable directory/filename traversal.
  18. *
  19. * cmDirectory provides a portable way of finding the names of the files
  20. * in a system directory.
  21. *
  22. * cmDirectory works with windows and unix only.
  23. */
  24. class cmDirectory
  25. {
  26. public:
  27. /**
  28. * Load the specified directory and load the names of the files
  29. * in that directory. 0 is returned if the directory can not be
  30. * opened, 1 if it is opened.
  31. */
  32. bool Load(const char* dir);
  33. /**
  34. * Return the number of files in the current directory.
  35. */
  36. int GetNumberOfFiles() { return m_Files.size();}
  37. /**
  38. * Return the file at the given index, the indexing is 0 based
  39. */
  40. const char* GetFile(unsigned int index);
  41. private:
  42. std::vector<std::string> m_Files; // Array of Files
  43. std::string m_Path; // Path to Open'ed directory
  44. }; // End Class: cmDirectory
  45. #endif