got new 4ed path working on linux

master
Allen Webster 2017-06-30 18:57:20 -04:00
parent 9862c8b926
commit 88de96e68a
4 changed files with 22 additions and 25 deletions

View File

@ -302,12 +302,6 @@ Sys_Directory_CD_Sig(system_directory_cd){
return(result); return(result);
} }
internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
String str = make_string_cap(out, 0, capacity);
return(system_get_binary_path(&str));
}
internal internal
Sys_Show_Mouse_Cursor_Sig(system_show_mouse_cursor){ Sys_Show_Mouse_Cursor_Sig(system_show_mouse_cursor){
linuxvars.hide_cursor = !show; linuxvars.hide_cursor = !show;

View File

@ -112,7 +112,7 @@ Sys_Font_Init_Sig(system_font_init){
u32 dir_max = KB(32); u32 dir_max = KB(32);
u8 *directory = push_array(scratch, u8, dir_max); u8 *directory = push_array(scratch, u8, dir_max);
String dir_str = make_string_cap(directory, 0, 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); Assert(dir_len < dir_max);
set_last_folder_sc(&dir_str, "fonts", '/'); set_last_folder_sc(&dir_str, "fonts", '/');

View File

@ -31,6 +31,25 @@ struct Unix_Vars{
static Unix_Vars unixvars; static Unix_Vars unixvars;
//
// 4ed Path
//
internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){
ssize_t size = readlink("/proc/self/exe", out, capacity - 1);
if (size != -1 && size < capacity - 1){
String str = make_string(out, size);
remove_last_folder(&str);
terminate_with_null(&str);
size = str.size;
}
else{
size = 0;
}
return(size);
}
// //
// Logging // Logging
// //
@ -63,21 +82,6 @@ Sys_File_Can_Be_Made_Sig(system_file_can_be_made){
return(result); return(result);
} }
internal
Sys_Get_Binary_Path_Sig(system_get_binary_path){
ssize_t size = readlink("/proc/self/exe", out->str, out->memory_size - 1);
if(size != -1 && size < out->memory_size - 1){
out->size = size;
remove_last_folder(out);
terminate_with_null(out);
size = out->size;
} else {
size = 0;
}
return size;
}
// //
// Memory // Memory
// //

View File

@ -217,15 +217,14 @@ global Application_Memory memory_vars;
internal internal
Sys_Get_4ed_Path_Sig(system_get_4ed_path){ Sys_Get_4ed_Path_Sig(system_get_4ed_path){
i32 result_size = 0;
i32 size = GetModuleFileName_utf8(0, (u8*)out, capacity); i32 size = GetModuleFileName_utf8(0, (u8*)out, capacity);
if (size < capacity - 1){ if (size < capacity - 1){
String str = make_string(out, size); String str = make_string(out, size);
remove_last_folder(&str); remove_last_folder(&str);
terminate_with_null(&str); terminate_with_null(&str);
result_size = str.size; size = str.size;
} }
return(result_size); return(size);
} }
// //