PathUtils.cpp 743 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "il2cpp-config.h"
  2. #include "utils/PathUtils.h"
  3. #include <string>
  4. namespace il2cpp
  5. {
  6. namespace utils
  7. {
  8. namespace PathUtils
  9. {
  10. std::string BasenameNoExtension(const std::string& path)
  11. {
  12. if (path.empty())
  13. return ".";
  14. std::string base = Basename(path);
  15. const size_t pos = base.rfind('.');
  16. // No extension.
  17. if (pos == std::string::npos)
  18. return base;
  19. return base.substr(0, pos);
  20. }
  21. std::string PathNoExtension(const std::string& path)
  22. {
  23. const size_t pos = path.rfind('.');
  24. // No extension.
  25. if (pos == std::string::npos)
  26. return path;
  27. return path.substr(0, pos);
  28. }
  29. }
  30. } /* utils */
  31. } /* il2cpp */