aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 20c5e28c9..397f41063 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -213,6 +213,10 @@ String string_trim_whitespace(String str) {
str.len--;
}
+ while (str.len > 0 && str[str.len-1] == 0) {
+ str.len--;
+ }
+
while (str.len > 0 && rune_is_whitespace(str[0])) {
str.text++;
str.len--;
@@ -267,6 +271,17 @@ String filename_from_path(String s) {
return make_string(nullptr, 0);
}
+String remove_directory_from_path(String s) {
+ isize len = 0;
+ for (isize i = s.len-1; i >= 0; i--) {
+ if (s[i] == '/' ||
+ s[i] == '\\') {
+ break;
+ }
+ len += 1;
+ }
+ return substring(s, s.len-len, s.len);
+}