FilePathSeparator.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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-03
  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::std::io
  14. {
  15. class LS_STD_DYNAMIC_GOAL FilePathSeparator
  16. {
  17. public:
  18. FilePathSeparator() = default;
  19. ~FilePathSeparator() = default;
  20. static char get()
  21. {
  22. char separator;
  23. #ifdef _WIN32
  24. separator = ls::std::io::FilePathSeparator::getWindowsFilePathSeparator();
  25. #endif
  26. #if defined(unix) || defined(__APPLE__)
  27. separator = ls::std::io::FilePathSeparator::getUnixFilePathSeparator();
  28. #endif
  29. return separator;
  30. }
  31. static char getUnixFilePathSeparator()
  32. {
  33. return '/';
  34. }
  35. static char getWindowsFilePathSeparator()
  36. {
  37. return '\\';
  38. }
  39. };
  40. }
  41. #endif