FilePathSeparator.hpp 1.1 KB

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