cmSystemTools.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /**
  12. * cmSystemTools - a collection of useful functions for CMake.
  13. */
  14. #ifndef cmSystemTools_h
  15. #define cmSystemTools_h
  16. #ifdef _MSC_VER
  17. #pragma warning ( disable : 4786 )
  18. #endif
  19. #include <string>
  20. #include <vector>
  21. #include <fstream>
  22. class cmSystemTools
  23. {
  24. public:
  25. /**
  26. * Make a new directory if it is not there. This function
  27. * can make a full path even if none of the directories existed
  28. * prior to calling this function.
  29. */
  30. static bool MakeDirectory(const char* path);
  31. /**
  32. * Replace replace all occurances of the string in in
  33. * souce string.
  34. */
  35. static void ReplaceString(std::string& source,
  36. const char* replace,
  37. const char* with);
  38. /**
  39. * Remove extra spaces and the trailing \ from a string.
  40. */
  41. static std::string CleanUpName(const char* name);
  42. /**
  43. * Replace windows slashes with unix style slashes
  44. */
  45. static void ConvertToUnixSlashes(std::string& path);
  46. /**
  47. * Return true if a file exists
  48. */
  49. static bool FileExists(const char* filename);
  50. /**
  51. * Return the number of times expression occurs in file in dir
  52. */
  53. static int Grep(const char* dir, const char* file, const char* expression);
  54. /**
  55. * Extract the right hand side of an asignment varibale = value
  56. */
  57. static std::string ExtractVariable(const char* varible,
  58. const char* line);
  59. /**
  60. * Read a list from a file into the array of strings.
  61. * This function assumes that the first line of the
  62. * list has been read. For example: NAME = \ was already
  63. * read in. The reading stops when there are no more
  64. * continuation characters.
  65. */
  66. static void ReadList(std::vector<std::string>& stringList,
  67. std::ifstream& fin);
  68. };
  69. #endif