Working on simplifying configurable allocation scheme
This commit is contained in:
@@ -115,14 +115,14 @@ os_write_file(String filename, String filecontent){
|
||||
}
|
||||
|
||||
CORE_Static String
|
||||
os_read_file(Arena *a, String name){
|
||||
os_read_file(Allocator *a, String name){
|
||||
String result = {0};
|
||||
FILE *f = fopen((char *)name.str, "rb");
|
||||
if(f){
|
||||
fseek(f, 0, SEEK_END);
|
||||
result.len = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
result.str = (U8 *)arena_push_size(a, result.len + 1);
|
||||
result.str = (U8 *)allocate_size(a, result.len + 1, false);
|
||||
fread(result.str, result.len, 1, f);
|
||||
fclose(f);
|
||||
result.str[result.len] = 0;
|
||||
@@ -132,7 +132,7 @@ os_read_file(Arena *a, String name){
|
||||
}
|
||||
|
||||
CORE_Static String
|
||||
os_get_working_dir(Arena *a){
|
||||
os_get_working_dir(Allocator *a){
|
||||
wchar_t buffer[2048];
|
||||
DWORD written = GetCurrentDirectoryW(2048, buffer);
|
||||
assert(written != 0);
|
||||
@@ -143,7 +143,7 @@ os_get_working_dir(Arena *a){
|
||||
}
|
||||
|
||||
CORE_Static String
|
||||
os_get_exe_dir(Arena *a){
|
||||
os_get_exe_dir(Allocator *a){
|
||||
wchar_t buffer[2048];
|
||||
DWORD written = GetModuleFileNameW(0, buffer, 2048);
|
||||
assert(written != 0);
|
||||
@@ -158,12 +158,13 @@ os_get_exe_dir(Arena *a){
|
||||
}
|
||||
|
||||
CORE_Static String
|
||||
os_get_absolute_path(Arena *a, String path){
|
||||
Scratch scratch(a);
|
||||
os_get_absolute_path(Allocator *a, String path){
|
||||
char buff[2048];
|
||||
Scratch_Arena *scratch = make_scratch_arena(buff, 2048);
|
||||
String16 path16 = string8_to_string16(scratch, path);
|
||||
|
||||
wchar_t *buffer = allocate_array(scratch, wchar_t, 2048);
|
||||
DWORD written = GetFullPathNameW((wchar_t *)path16.str, 2048, buffer, 0);
|
||||
wchar_t *buffer = allocate_array(scratch, wchar_t, 512);
|
||||
DWORD written = GetFullPathNameW((wchar_t *)path16.str, 512, buffer, 0);
|
||||
if(written == 0) return {};
|
||||
|
||||
String16 absolute16 = string16_from_widechar(buffer);
|
||||
@@ -174,7 +175,8 @@ os_get_absolute_path(Arena *a, String path){
|
||||
|
||||
CORE_Static B32
|
||||
os_does_file_exist(String path){
|
||||
Scratch scratch;
|
||||
char buff[2048];
|
||||
Scratch_Arena *scratch = make_scratch_arena(buff, buff_cap(buff));
|
||||
String16 path16 = string8_to_string16(scratch, path);
|
||||
DWORD attribs = GetFileAttributesW((wchar_t *)path16.str);
|
||||
B32 result = attribs == INVALID_FILE_ATTRIBUTES ? false : true;
|
||||
@@ -182,8 +184,8 @@ os_does_file_exist(String path){
|
||||
}
|
||||
|
||||
CORE_Static Array<OS_File_Info>
|
||||
os_list_dir(Arena *a, String dir, U32 flags = LIST_NO_FLAGS){
|
||||
Scratch scratch(a);
|
||||
os_list_dir(Scratch_Arena *scratch, Allocator *a, String dir, U32 flags = LIST_NO_FLAGS){
|
||||
Scratch_Scope _scope(scratch);
|
||||
Array<String> dirs_to_read = {scratch};
|
||||
dirs_to_read.add(dir);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user