1 #include "test_precomp.hpp" 2 3 cv::String cv::Path::combine(const String& item1, const String& item2) 4 { 5 if (item1.empty()) 6 return item2; 7 8 if (item2.empty()) 9 return item1; 10 11 char last = item1[item1.size()-1]; 12 13 bool need_append = last != '/' && last != '\\'; 14 return item1 + (need_append ? "/" : "") + item2; 15 } 16 17 cv::String cv::Path::combine(const String& item1, const String& item2, const String& item3) 18 { return combine(combine(item1, item2), item3); } 19 20 cv::String cv::Path::change_extension(const String& file, const String& ext) 21 { 22 String::size_type pos = file.find_last_of('.'); 23 return pos == String::npos ? file : file.substr(0, pos+1) + ext; 24 } 25