Base.cpp 622 B

1234567891011121314151617181920212223242526
  1. #include "Base.h"
  2. namespace gameplay
  3. {
  4. void fillArray(float values[], float value, size_t length)
  5. {
  6. for (size_t i = 0; i < length; ++i)
  7. {
  8. values[i] = value;
  9. }
  10. }
  11. std::string getBaseName(const std::string& filepath)
  12. {
  13. size_t index1 = filepath.find_last_of('\\');
  14. size_t index2 = filepath.find_last_of('/');
  15. size_t index = (index1 != -1 && index1 > index2 ? index1 : index2);
  16. size_t length = filepath.length();
  17. std::string filename = filepath.substr(index + 1, length);
  18. length = filename.length();
  19. std::string output = filename.substr(0, (length-4));
  20. return output;
  21. }
  22. }