summaryrefslogtreecommitdiff
path: root/source/base/base_os.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/base/base_os.h')
-rw-r--r--source/base/base_os.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/base/base_os.h b/source/base/base_os.h
index abe8628..9397fbb 100644
--- a/source/base/base_os.h
+++ b/source/base/base_os.h
@@ -2,21 +2,28 @@
2#define BASE_OS_H 2#define BASE_OS_H
3 3
4internal string8 4internal string8
5load_file(const char *path) 5load_file(mem_arena *arena, const char *path)
6{ 6{
7 string8 result = {0}; 7 string8 result = {0};
8 struct stat sbuf = {0}; 8 struct stat sbuf = {0};
9 9
10 s32 file = open(path, O_RDONLY); 10 s32 file = open(path, O_RDONLY);
11 if(file == -1) return result; 11 if(file == -1)
12 {
13 warn("fialed to open file. path could be invalid");
14 return (string8){0};
15 }
12 16
13 if(fstat(file, &sbuf) == -1) 17 if(fstat(file, &sbuf) == -1)
14 { 18 {
15 print("error: fstat failed"); 19 warn("error: fstat failed");
16 close(file); 20 close(file);
17 return result; 21 return (string8){0};
18 } 22 }
19 23
24
25 result = PushString(arena, sbuf.st_size);
26
20 result.size = (u64)sbuf.st_size; 27 result.size = (u64)sbuf.st_size;
21 if(result.size != 0) 28 if(result.size != 0)
22 { 29 {