summaryrefslogtreecommitdiff
path: root/Source/Core/Common/StringUtil.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2016-11-26 15:39:00 +0100
committerJosJuice <josjuice@gmail.com>2016-11-26 22:49:46 +0100
commitc74c317ab574779524fe2e20136aed03044d6b3a (patch)
tree4dbdae28e97498d6d246f7aed5f5602d50c261f0 /Source/Core/Common/StringUtil.cpp
parentde355a8521d47e8c86dffab0470a8acead1af746 (diff)
IOS HLE: More robust escaping of NAND paths
Prevents path traversal without needing an absolute path function, and also improves accuracy (character sequences like ../ appear to have no special meaning in IOS). This removes the creation and usage of /sys/replace, because the new escapes are too complicated to all be representable in its format and because no other NAND handling software seems to use /sys/replace.
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
-rw-r--r--Source/Core/Common/StringUtil.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp
index 5048446682..6f3567e782 100644
--- a/Source/Core/Common/StringUtil.cpp
+++ b/Source/Core/Common/StringUtil.cpp
@@ -10,7 +10,9 @@
#include <cstring>
#include <iomanip>
#include <istream>
+#include <iterator>
#include <limits.h>
+#include <sstream>
#include <string>
#include <vector>
@@ -328,6 +330,21 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
output.pop_back();
}
+std::string JoinStrings(const std::vector<std::string>& strings, const std::string& delimiter)
+{
+ // Check if we can return early, just for speed
+ if (strings.empty())
+ return "";
+
+ std::stringstream res;
+ std::copy(strings.begin(), strings.end(),
+ std::ostream_iterator<std::string>(res, delimiter.c_str()));
+
+ // Drop the trailing delimiter.
+ std::string joined = res.str();
+ return joined.substr(0, joined.length() - delimiter.length());
+}
+
std::string TabsToSpaces(int tab_size, const std::string& in)
{
const std::string spaces(tab_size, ' ');