FilePathSeparator.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-15
  6. * Changed: 2022-07-01
  7. *
  8. * */
  9. #ifndef FILE_PATH_SEPARATOR_HPP
  10. #define FILE_PATH_SEPARATOR_HPP
  11. #include <string>
  12. #include <ls_std/os/dynamic_goal.hpp>
  13. namespace ls
  14. {
  15. namespace std
  16. {
  17. namespace io
  18. {
  19. class DYNAMIC_GOAL FilePathSeparator
  20. {
  21. public:
  22. FilePathSeparator() = default;
  23. ~FilePathSeparator() = default;
  24. static char get()
  25. {
  26. char separator;
  27. #ifdef _WIN32
  28. separator = ls::std::io::FilePathSeparator::getWindowsFilePathSeparator();
  29. #endif
  30. #if defined(unix) || defined(__APPLE__)
  31. separator = ls::std::io::FilePathSeparator::getUnixFilePathSeparator();
  32. #endif
  33. return separator;
  34. }
  35. static char getUnixFilePathSeparator()
  36. {
  37. return '/';
  38. }
  39. static char getWindowsFilePathSeparator()
  40. {
  41. return '\\';
  42. }
  43. };
  44. }
  45. }
  46. }
  47. #endif