|
|
@@ -3767,6 +3767,32 @@ bool SystemTools::Split(const std::string& str,
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+std::string SystemTools::Join(const std::vector<std::string>& list,
|
|
|
+ const std::string& separator)
|
|
|
+{
|
|
|
+ std::string result;
|
|
|
+ if (list.empty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ size_t total_size = separator.size() * (list.size() - 1);
|
|
|
+ for (const std::string& string : list) {
|
|
|
+ total_size += string.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ result.reserve(total_size);
|
|
|
+ bool needs_separator = false;
|
|
|
+ for (const std::string& string : list) {
|
|
|
+ if (needs_separator) {
|
|
|
+ result += separator;
|
|
|
+ }
|
|
|
+ result += string;
|
|
|
+ needs_separator = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Return path of a full filename (no trailing slashes).
|
|
|
* Warning: returned path is converted to Unix slashes format.
|