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
combine(const String & item1,const String & item2)6 cv::String cv::Path::combine(const String& item1, const String& item2)
7 {
8 if (item1.empty())
9 return item2;
10
11 if (item2.empty())
12 return item1;
13
14 char last = item1[item1.size()-1];
15
16 bool need_append = last != '/' && last != '\\';
17 return item1 + (need_append ? "/" : "") + item2;
18 }
19
combine(const String & item1,const String & item2,const String & item3)20 cv::String cv::Path::combine(const String& item1, const String& item2, const String& item3)
21 { return combine(combine(item1, item2), item3); }
22
change_extension(const String & file,const String & ext)23 cv::String cv::Path::change_extension(const String& file, const String& ext)
24 {
25 String::size_type pos = file.find_last_of('.');
26 return pos == String::npos ? file : file.substr(0, pos+1) + ext;
27 }
28