override user directory on command line
This commit is contained in:
parent
e3efa89293
commit
fb4d181a3b
9
4ed.cpp
9
4ed.cpp
|
@ -52,6 +52,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
|
|
||||||
case 'f': action = CLAct_FontSize; break;
|
case 'f': action = CLAct_FontSize; break;
|
||||||
case 'h': action = CLAct_FontUseHinting; --i; break;
|
case 'h': action = CLAct_FontUseHinting; --i; break;
|
||||||
|
case 'U': action = CLAct_UserDirectory; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arg[0] != 0){
|
else if (arg[0] != 0){
|
||||||
|
@ -137,6 +138,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||||
settings->use_hinting = plat_settings->use_hinting;
|
settings->use_hinting = plat_settings->use_hinting;
|
||||||
action = CLAct_Nothing;
|
action = CLAct_Nothing;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
case CLAct_UserDirectory:
|
||||||
|
{
|
||||||
|
if (i < argc){
|
||||||
|
plat_settings->user_directory = argv[i];
|
||||||
|
}
|
||||||
|
action = CLAct_Nothing;
|
||||||
|
}break;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
|
28
4ed.h
28
4ed.h
|
@ -28,16 +28,18 @@ struct Plat_Settings{
|
||||||
b8 maximize_window;
|
b8 maximize_window;
|
||||||
|
|
||||||
b8 use_hinting;
|
b8 use_hinting;
|
||||||
|
|
||||||
|
char *user_directory;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define App_Read_Command_Line_Sig(name) \
|
#define App_Read_Command_Line_Sig(name) \
|
||||||
void *name(Thread_Context *tctx,\
|
void *name(Thread_Context *tctx,\
|
||||||
String_Const_u8 current_directory,\
|
String_Const_u8 current_directory,\
|
||||||
Plat_Settings *plat_settings,\
|
Plat_Settings *plat_settings,\
|
||||||
char ***files, \
|
char ***files, \
|
||||||
i32 **file_count,\
|
i32 **file_count,\
|
||||||
i32 argc, \
|
i32 argc, \
|
||||||
char **argv)
|
char **argv)
|
||||||
|
|
||||||
typedef App_Read_Command_Line_Sig(App_Read_Command_Line);
|
typedef App_Read_Command_Line_Sig(App_Read_Command_Line);
|
||||||
|
|
||||||
|
@ -48,10 +50,10 @@ struct Custom_API{
|
||||||
|
|
||||||
#define App_Init_Sig(name) \
|
#define App_Init_Sig(name) \
|
||||||
void name(Thread_Context *tctx, \
|
void name(Thread_Context *tctx, \
|
||||||
Render_Target *target, \
|
Render_Target *target, \
|
||||||
void *base_ptr, \
|
void *base_ptr, \
|
||||||
String_Const_u8 current_directory,\
|
String_Const_u8 current_directory,\
|
||||||
Custom_API api)
|
Custom_API api)
|
||||||
|
|
||||||
typedef App_Init_Sig(App_Init);
|
typedef App_Init_Sig(App_Init);
|
||||||
|
|
||||||
|
@ -77,9 +79,9 @@ struct Application_Step_Input{
|
||||||
|
|
||||||
#define App_Step_Sig(name) Application_Step_Result \
|
#define App_Step_Sig(name) Application_Step_Result \
|
||||||
name(Thread_Context *tctx, \
|
name(Thread_Context *tctx, \
|
||||||
Render_Target *target, \
|
Render_Target *target, \
|
||||||
void *base_ptr, \
|
void *base_ptr, \
|
||||||
Application_Step_Input *input)
|
Application_Step_Input *input)
|
||||||
|
|
||||||
typedef App_Step_Sig(App_Step);
|
typedef App_Step_Sig(App_Step);
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,6 @@ struct File_Init{
|
||||||
enum Command_Line_Action{
|
enum Command_Line_Action{
|
||||||
CLAct_Nothing,
|
CLAct_Nothing,
|
||||||
CLAct_Ignore,
|
CLAct_Ignore,
|
||||||
CLAct_UserFile,
|
|
||||||
CLAct_CustomDLL,
|
CLAct_CustomDLL,
|
||||||
CLAct_WindowSize,
|
CLAct_WindowSize,
|
||||||
CLAct_WindowMaximize,
|
CLAct_WindowMaximize,
|
||||||
|
@ -188,6 +187,7 @@ enum Command_Line_Action{
|
||||||
CLAct_WindowFullscreen,
|
CLAct_WindowFullscreen,
|
||||||
CLAct_FontSize,
|
CLAct_FontSize,
|
||||||
CLAct_FontUseHinting,
|
CLAct_FontUseHinting,
|
||||||
|
CLAct_UserDirectory,
|
||||||
//
|
//
|
||||||
CLAct_COUNT,
|
CLAct_COUNT,
|
||||||
};
|
};
|
||||||
|
|
|
@ -167,11 +167,6 @@ save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal b32
|
|
||||||
save_file(Thread_Context *tctx, Models *models, Editing_File *file){
|
|
||||||
return(save_file_to_name(tctx, models, file, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal Buffer_Cursor
|
internal Buffer_Cursor
|
||||||
|
|
|
@ -1835,6 +1835,11 @@ main(int argc, char **argv){
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): setup user directory override
|
||||||
|
if (plat_settings.user_directory != 0){
|
||||||
|
lnx_override_user_directory = plat_settings.user_directory;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(allen): load custom layer
|
// NOTE(allen): load custom layer
|
||||||
System_Library custom_library = {};
|
System_Library custom_library = {};
|
||||||
Custom_API custom = {};
|
Custom_API custom = {};
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
global char *lnx_override_user_directory = 0;
|
||||||
|
|
||||||
internal String_Const_u8
|
internal String_Const_u8
|
||||||
system_get_path(Arena* arena, System_Path_Code path_code){
|
system_get_path(Arena* arena, System_Path_Code path_code){
|
||||||
String_Const_u8 result = {};
|
String_Const_u8 result = {};
|
||||||
|
@ -45,10 +47,15 @@ system_get_path(Arena* arena, System_Path_Code path_code){
|
||||||
|
|
||||||
case SystemPath_UserDirectory:
|
case SystemPath_UserDirectory:
|
||||||
{
|
{
|
||||||
|
if (lnx_override_user_directory == 0){
|
||||||
char *home_cstr = getenv("HOME");
|
char *home_cstr = getenv("HOME");
|
||||||
if (home_cstr != 0){
|
if (home_cstr != 0){
|
||||||
result = push_u8_stringf(arena, "%s/.4coder/", home_cstr);
|
result = push_u8_stringf(arena, "%s/.4coder/", home_cstr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result = SCu8((u8*)lnx_override_user_directory);
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1738,6 +1738,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen): setup user directory override
|
||||||
|
if (plat_settings.user_directory != 0){
|
||||||
|
w32_override_user_directory = SCu8((u8*)plat_settings.user_directory);
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(allen): load custom layer
|
// NOTE(allen): load custom layer
|
||||||
System_Library custom_library = {};
|
System_Library custom_library = {};
|
||||||
Custom_API custom = {};
|
Custom_API custom = {};
|
||||||
|
|
|
@ -125,6 +125,8 @@ system_memory_annotation_sig(){
|
||||||
extern "C" BOOL CALL_CONVENTION
|
extern "C" BOOL CALL_CONVENTION
|
||||||
GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize);
|
GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize);
|
||||||
|
|
||||||
|
global String_Const_u8 w32_override_user_directory = {};
|
||||||
|
|
||||||
internal
|
internal
|
||||||
system_get_path_sig(){
|
system_get_path_sig(){
|
||||||
String_Const_u8 result = {};
|
String_Const_u8 result = {};
|
||||||
|
@ -155,6 +157,7 @@ system_get_path_sig(){
|
||||||
|
|
||||||
case SystemPath_UserDirectory:
|
case SystemPath_UserDirectory:
|
||||||
{
|
{
|
||||||
|
if (w32_override_user_directory.size == 0){
|
||||||
HANDLE current_process_token = GetCurrentProcessToken();
|
HANDLE current_process_token = GetCurrentProcessToken();
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
GetUserProfileDirectoryW(current_process_token, 0, &size);
|
GetUserProfileDirectoryW(current_process_token, 0, &size);
|
||||||
|
@ -163,6 +166,10 @@ system_get_path_sig(){
|
||||||
String8 path = string_u8_from_string_u16(arena, SCu16(buffer_u16, size), StringFill_NullTerminate).string;
|
String8 path = string_u8_from_string_u16(arena, SCu16(buffer_u16, size), StringFill_NullTerminate).string;
|
||||||
result = push_stringf(arena, "%.*s\\4coder\\", string_expand(path));
|
result = push_stringf(arena, "%.*s\\4coder\\", string_expand(path));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
result = w32_override_user_directory;
|
||||||
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
|
Loading…
Reference in New Issue