test_common.cpp 881 B

123456789101112131415161718192021222324252627
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "test_precomp.hpp"
  5. cv::String cv::Path::combine(const String& item1, const String& item2)
  6. {
  7. if (item1.empty())
  8. return item2;
  9. if (item2.empty())
  10. return item1;
  11. char last = item1[item1.size()-1];
  12. bool need_append = last != '/' && last != '\\';
  13. return item1 + (need_append ? "/" : "") + item2;
  14. }
  15. cv::String cv::Path::combine(const String& item1, const String& item2, const String& item3)
  16. { return combine(combine(item1, item2), item3); }
  17. cv::String cv::Path::change_extension(const String& file, const String& ext)
  18. {
  19. String::size_type pos = file.find_last_of('.');
  20. return pos == String::npos ? file : file.substr(0, pos+1) + ext;
  21. }