From df578d6ec58e678e30b90601550f82ac4153b3e8 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 27 May 2018 11:40:27 +0100 Subject: Allow for either .odin file or directory as the initial start --- src/string.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/string.cpp') diff --git a/src/string.cpp b/src/string.cpp index 32d97184a..96e17f58f 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -287,6 +287,16 @@ String remove_directory_from_path(String const &s) { } return substring(s, s.len-len, s.len); } +String directory_from_path(String const &s) { + isize i = s.len-1; + for (; i >= 0; i--) { + if (s[i] == '/' || + s[i] == '\\') { + break; + } + } + return substring(s, 0, i); +} String concatenate_strings(gbAllocator a, String const &x, String const &y) { -- cgit v1.2.3