CmPath.h 838 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #include <boost/filesystem.hpp>
  4. namespace CamelotEngine
  5. {
  6. /**
  7. * @brief Various utility methods for handling file paths.
  8. */
  9. class Path
  10. {
  11. public:
  12. static bool exists(const String& path)
  13. {
  14. return boost::filesystem::exists(path);
  15. }
  16. static String getExtension(const String& path)
  17. {
  18. return boost::filesystem::extension(path);
  19. }
  20. static bool isAbsolute(const String& path)
  21. {
  22. #if CM_PLATFORM == CM_PLATFORM_WIN32
  23. if (isalpha(UINT8(path[0])) && path[1] == ':')
  24. return true;
  25. #endif
  26. return path[0] == '/' || path[0] == '\\';
  27. }
  28. static String concatenatePath(const String& base, const String& name)
  29. {
  30. if (base.empty() || isAbsolute(name.c_str()))
  31. return name;
  32. else
  33. return base + '/' + name;
  34. }
  35. };
  36. }