FilePathSeparator.hpp 955 B

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