aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-08-27 14:42:19 +0100
committerGinger Bill <bill@gingerbill.org>2017-08-27 14:42:19 +0100
commit6707c8750e951ed6533ab3d4240314cf0bba7147 (patch)
tree81c3da56ac6f26fd5e51beb8e0433a5c0fbf563f /src/string.cpp
parente5502c13eef07b3cef9947c47b133555e33b8d85 (diff)
Import cycle checking
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);
+}