aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-07-21 00:38:15 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-07-21 00:38:15 +0100
commit51d0532c3e56ca0816da20f6f3e59d2d0f2c55c9 (patch)
tree5449b119787acd8e49b08af2003aaa7c423597e8 /src/common.cpp
parentcbd82e3c02cbeff8fe3ba5198d6ca730f8c1eace (diff)
Only allow .odin files to be parsed
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 7d7bed316..e5b674c3b 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -31,6 +31,35 @@ gb_inline b32 are_strings_equal(String a, String b) {
return false;
}
+
+gb_inline isize string_has_any_extension(String str) {
+ isize dot_pos = -1;
+ isize i = str.len;
+ b32 seen_dot = false;
+ while (i --> 0) {
+ if (str.text[i] == GB_PATH_SEPARATOR)
+ break;
+ if (str.text[i] == '.') {
+ dot_pos = i;
+ break;
+ }
+ }
+
+ return dot_pos;
+}
+
+gb_inline b32 string_has_extension(String str, String ext) {
+ if (str.len > ext.len+1) {
+ u8 *s = str.text+str.len - ext.len-1;
+ if (s[0] == '.') {
+ s++;
+ return gb_memcompare(s, ext.text, ext.len) == 0;
+ }
+ return false;
+ }
+ return false;
+}
+
// Hasing
gb_inline u64 hashing_proc(void const *data, isize len) {