Added a way for executable path configs

To use, all you need to do is put your config folders in a subdirectory called .pcem in
the directory the EXE is located in.

If the .pcem directory exists in the same directory as the exe it will use it for configs.
This commit is contained in:
Michael J. Manley
2023-03-03 13:19:14 -08:00
parent 06af0482dd
commit 7a49e96c80
3 changed files with 9 additions and 5 deletions

View File

@@ -230,10 +230,12 @@ void get_pcem_path(char *s, int size) {
mkdir(s, 0700); mkdir(s, 0700);
} }
#else #else
wx_get_home_directory(s); char* sdlBasePath = SDL_GetBasePath();
strcpy(s, sdlBasePath);
strcat(s, ".pcem/"); strcat(s, ".pcem/");
if(!wx_dir_exists(s)) {
if (!wx_dir_exists(pcem_path)) wx_get_home_directory(s);
wx_create_directory(pcem_path); strcat(s, ".pcem/");
}
#endif #endif
} }

View File

@@ -31,7 +31,7 @@ set(PCEM_SRC_PLUGINAPI
if(PLUGIN_ENGINE) if(PLUGIN_ENGINE)
add_library(pcem-plugin-api SHARED ${PCEM_SRC_PLUGINAPI} ${PCEM_PUBLIC_API}) add_library(pcem-plugin-api SHARED ${PCEM_SRC_PLUGINAPI} ${PCEM_PUBLIC_API})
target_link_libraries(pcem-plugin-api ${DISPLAY_ENGINE_LIBRARIES}) target_link_libraries(pcem-plugin-api ${SDL2_LIBRARIES} ${DISPLAY_ENGINE_LIBRARIES})
target_compile_definitions(pcem-plugin-api PUBLIC ${PCEM_DEFINES}) target_compile_definitions(pcem-plugin-api PUBLIC ${PCEM_DEFINES})
install(TARGETS pcem-plugin-api RUNTIME DESTINATION ${PCEM_BIN_DIR} LIBRARY DESTINATION ${PCEM_LIB_DIR} ARCHIVE DESTINATION ${PCEM_LIB_DIR}) install(TARGETS pcem-plugin-api RUNTIME DESTINATION ${PCEM_BIN_DIR} LIBRARY DESTINATION ${PCEM_LIB_DIR} ARCHIVE DESTINATION ${PCEM_LIB_DIR})
set(PCEM_LIBRARIES ${PCEM_LIBRARIES} pcem-plugin-api) set(PCEM_LIBRARIES ${PCEM_LIBRARIES} pcem-plugin-api)

View File

@@ -418,6 +418,8 @@ void sdl_onconfigloaded() {
wx_callback(ghwnd, wx_setupmenu, 0); wx_callback(ghwnd, wx_setupmenu, 0);
/* create directories */ /* create directories */
if (!wx_dir_exists(pcem_path))
wx_create_directory(pcem_path);
if (!wx_dir_exists(configs_path)) if (!wx_dir_exists(configs_path))
wx_create_directory(configs_path); wx_create_directory(configs_path);
if (!wx_dir_exists(nvr_path)) if (!wx_dir_exists(nvr_path))