Filesystem.cpp 740 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (C) 2009-2020, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <anki/util/Filesystem.h>
  6. namespace anki
  7. {
  8. void getFilepathExtension(const CString& filename, StringAuto& out)
  9. {
  10. const char* pc = std::strrchr(filename.cstr(), '.');
  11. if(pc == nullptr)
  12. {
  13. // Do nothing
  14. }
  15. else
  16. {
  17. ++pc;
  18. if(*pc != '\0')
  19. {
  20. out.create(CString(pc));
  21. }
  22. }
  23. }
  24. void getFilepathFilename(const CString& filename, StringAuto& out)
  25. {
  26. const char* pc = std::strrchr(filename.cstr(), '/');
  27. if(pc == nullptr)
  28. {
  29. // Do nothing
  30. }
  31. else
  32. {
  33. ++pc;
  34. if(*pc != '\0')
  35. {
  36. out.create(CString(pc));
  37. }
  38. }
  39. }
  40. } // end namespace anki