cleaned up the binary path getter on win32
parent
deb9e46bdf
commit
9862c8b926
|
@ -199,7 +199,7 @@ typedef Sys_Acquire_Lock_Sig(System_Acquire_Lock);
|
|||
#define Sys_Release_Lock_Sig(name) void name(i32 id)
|
||||
typedef Sys_Release_Lock_Sig(System_Release_Lock);
|
||||
|
||||
// needed for custom layer
|
||||
// memory
|
||||
#define Sys_Memory_Allocate_Sig(name) void* name(umem size)
|
||||
typedef Sys_Memory_Allocate_Sig(System_Memory_Allocate);
|
||||
|
||||
|
@ -209,6 +209,7 @@ typedef Sys_Memory_Set_Protection_Sig(System_Memory_Set_Protection);
|
|||
#define Sys_Memory_Free_Sig(name) void name(void *ptr, umem size)
|
||||
typedef Sys_Memory_Free_Sig(System_Memory_Free);
|
||||
|
||||
// file system
|
||||
#define Sys_File_Exists_Sig(name) b32 name(char *filename, i32 len)
|
||||
typedef Sys_File_Exists_Sig(System_File_Exists);
|
||||
|
||||
|
@ -218,6 +219,7 @@ typedef Sys_Directory_CD_Sig(System_Directory_CD);
|
|||
#define Sys_Get_4ed_Path_Sig(name) int32_t name(char *out, i32 capacity)
|
||||
typedef Sys_Get_4ed_Path_Sig(System_Get_4ed_Path);
|
||||
|
||||
// behavior and appearance options
|
||||
#define Sys_Show_Mouse_Cursor_Sig(name) void name(i32 show)
|
||||
typedef Sys_Show_Mouse_Cursor_Sig(System_Show_Mouse_Cursor);
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@
|
|||
// Standard implementation of file system stuff based on the file track layer.
|
||||
//
|
||||
|
||||
internal i32
|
||||
system_get_binary_path_string(String *out){
|
||||
out->size = system_get_4ed_path(out->str, out->memory_size);
|
||||
return(out->size);
|
||||
}
|
||||
|
||||
internal void
|
||||
init_shared_vars(){
|
||||
umem scratch_size = KB(128);
|
||||
|
@ -206,7 +212,7 @@ internal b32
|
|||
sysshared_to_binary_path(String *out_filename, char *filename){
|
||||
b32 translate_success = 0;
|
||||
i32 max = out_filename->memory_size;
|
||||
i32 size = system_get_binary_path(out_filename);
|
||||
i32 size = system_get_binary_path_string(out_filename);
|
||||
if (size > 0 && size < max-1){
|
||||
out_filename->size = size;
|
||||
if (append_sc(out_filename, filename) && terminate_with_null(out_filename)){
|
||||
|
|
|
@ -25,10 +25,12 @@ struct File_Data{
|
|||
global File_Data null_file_data = {0};
|
||||
|
||||
#define Sys_File_Can_Be_Made_Sig(name) b32 name(u8 *filename)
|
||||
#define Sys_Get_Binary_Path_Sig(name) i32 name(String *out)
|
||||
|
||||
internal Sys_File_Can_Be_Made_Sig(system_file_can_be_made);
|
||||
|
||||
#if 0
|
||||
#define Sys_Get_Binary_Path_Sig(name) i32 name(String *out)
|
||||
internal Sys_Get_Binary_Path_Sig(system_get_binary_path);
|
||||
#endif
|
||||
|
||||
struct Shared_Vars{
|
||||
File_Track_System track;
|
||||
|
|
|
@ -211,6 +211,23 @@ struct Win32_Vars{
|
|||
global Win32_Vars win32vars;
|
||||
global Application_Memory memory_vars;
|
||||
|
||||
//
|
||||
// 4ed path
|
||||
//
|
||||
|
||||
internal
|
||||
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
|
||||
i32 result_size = 0;
|
||||
i32 size = GetModuleFileName_utf8(0, (u8*)out, capacity);
|
||||
if (size < capacity - 1){
|
||||
String str = make_string(out, size);
|
||||
remove_last_folder(&str);
|
||||
terminate_with_null(&str);
|
||||
result_size = str.size;
|
||||
}
|
||||
return(result_size);
|
||||
}
|
||||
|
||||
//
|
||||
// Logging
|
||||
//
|
||||
|
@ -220,7 +237,7 @@ Sys_Log_Sig(system_log){
|
|||
if (win32vars.settings.use_log){
|
||||
u8 space[4096];
|
||||
String str = make_fixed_width_string(space);
|
||||
system_get_binary_path(&str);
|
||||
str.size = system_get_4ed_path(str.str, str.memory_size);
|
||||
append_sc(&str, "4coder_log.txt");
|
||||
terminate_with_null(&str);
|
||||
HANDLE file = CreateFile_utf8(space, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
@ -1037,19 +1054,6 @@ Win32DirectoryExists(char *path){
|
|||
return(attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Get_Binary_Path_Sig(system_get_binary_path){
|
||||
i32 result = 0;
|
||||
i32 size = GetModuleFileName_utf8(0, (u8*)out->str, out->memory_size);
|
||||
if (size < out->memory_size-1){
|
||||
out->size = size;
|
||||
remove_last_folder(out);
|
||||
terminate_with_null(out);
|
||||
result = out->size;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_File_Exists_Sig(system_file_exists){
|
||||
char full_filename_space[1024];
|
||||
|
@ -1112,13 +1116,6 @@ Sys_Directory_CD_Sig(system_directory_cd){
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
|
||||
String str = make_string_cap(out, 0, capacity);
|
||||
int32_t size = system_get_binary_path(&str);
|
||||
return(size);
|
||||
}
|
||||
|
||||
/*
|
||||
NOTE(casey): This follows Raymond Chen's prescription
|
||||
for fullscreen toggling, see:
|
||||
|
|
|
@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
|
|||
u32 dir_max = KB(32);
|
||||
u8 *directory = push_array(scratch, u8, dir_max);
|
||||
String dir_str = make_string_cap(directory, 0, dir_max);
|
||||
u32 dir_len = system_get_binary_path(&dir_str);
|
||||
u32 dir_len = system_get_binary_path_string(&dir_str);
|
||||
Assert(dir_len < dir_max);
|
||||
|
||||
set_last_folder_sc(&dir_str, "fonts", '\\');
|
||||
|
|
Loading…
Reference in New Issue