aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp
index f23a330..c36a64a 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -32,6 +32,28 @@ namespace gsr {
return str.size() >= len && memcmp(str.data() + str.size() - len, substr, len) == 0;
}
+ std::string strip(const std::string &str) {
+ int start_index = 0;
+ int str_len = str.size();
+
+ for(int i = 0; i < str_len; ++i) {
+ if(str[i] != ' ') {
+ start_index += i;
+ str_len -= i;
+ break;
+ }
+ }
+
+ for(int i = str_len - 1; i >= 0; --i) {
+ if(str[i] != ' ') {
+ str_len = i + 1;
+ break;
+ }
+ }
+
+ return str.substr(start_index, str_len);
+ }
+
std::string get_home_dir() {
const char *home_dir = getenv("HOME");
if(!home_dir) {