diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index 2f04242894..56b0b2ca4d 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -17,10 +17,13 @@ #include #include #include +#include +#include #include #include +#include #include "../../defaults.h" #include "../../dynamic.h" @@ -49,18 +52,122 @@ static int frontend_qnx_get_rating(void) static void frontend_qnx_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { - fill_pathname_join(g_defaults.path.config, "app/native", - file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); - fill_pathname_join(g_defaults.dir.shader, "app/native", - "shaders_glsl", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.dir.overlay, "app/native", - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.core, "app/native", - "lib", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, "app/native", + char assets_path[PATH_MAX] = {0}; + char data_path[PATH_MAX] = {0}; + char user_path[PATH_MAX] = {0}; + char tmp_path[PATH_MAX] = {0}; + + char workdir[PATH_MAX] = {0}; + getcwd(workdir, sizeof(workdir)); + + if(!string_is_empty(workdir)) + { + snprintf(assets_path, sizeof(data_path), + "%s/app/native/assets", workdir); + snprintf(data_path, sizeof(data_path), + "%s/data", workdir); + snprintf(user_path, sizeof(user_path), + "%s/shared/misc/retroarch", workdir); + snprintf(tmp_path, sizeof(user_path), + "%s/tmp", workdir); + } + else + { + snprintf(assets_path, sizeof(data_path), "app/native/assets"); + snprintf(data_path, sizeof(data_path), "data"); + snprintf(user_path, sizeof(user_path), "shared/misc/retroarch"); + snprintf(tmp_path, sizeof(user_path), "tmp"); + } + + // app data + fill_pathname_join(g_defaults.dir.core, data_path, + "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.assets, data_path, + "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.autoconfig, data_path, + "autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dir.cursor, data_path, + "database/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dir.database, data_path, + "database/rdb", sizeof(g_defaults.dir.database)); + fill_pathname_join(g_defaults.dir.core_info, data_path, "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.playlist, "app/native", + fill_pathname_join(g_defaults.dir.overlay, data_path, + "overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.shader, data_path, + "shaders", sizeof(g_defaults.dir.shader)); + + // user data + fill_pathname_join(g_defaults.dir.cheats, user_path, + "cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.menu_config, user_path, + "config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.menu_content, user_path, + "content", sizeof(g_defaults.dir.menu_content)); + fill_pathname_join(g_defaults.dir.core_assets, user_path, + "downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.audio_filter, user_path, + "filters/audio", sizeof(g_defaults.dir.audio_filter)); + fill_pathname_join(g_defaults.dir.video_filter, user_path, + "filters/video", sizeof(g_defaults.dir.video_filter)); + fill_pathname_join(g_defaults.dir.playlist, user_path, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.remap, user_path, + "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.sram, user_path, + "saves", sizeof(g_defaults.dir.sram)); + fill_pathname_join(g_defaults.dir.screenshot, user_path, + "screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dir.savestate, user_path, + "states", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dir.system, user_path, + "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dir.thumbnails, user_path, + "thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_join(g_defaults.dir.wallpapers, user_path, + "wallpapers", sizeof(g_defaults.dir.wallpapers)); + + // tmp + strlcpy(g_defaults.dir.cache, tmp_path, sizeof(g_defaults.dir.cache)); + + // history and main config + strlcpy(g_defaults.dir.content_history, + user_path, sizeof(g_defaults.dir.content_history)); + fill_pathname_join(g_defaults.path.config, user_path, + file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); + + // bundle copy + char data_assets_path[PATH_MAX] = {0}; + sprintf(data_assets_path, "%s/%s", data_path, "assets"); + if(!path_file_exists(data_assets_path)) + { + RARCH_LOG( "Copying application assets to data directory...\n" ); + + char copy_command[PATH_MAX] = {0}; + sprintf(copy_command, "cp -r %s/. %s", assets_path, data_path); + + if(system(copy_command) == -1) { + RARCH_LOG( "Asset copy failed: Shell could not be run.\n" ); + } else { + RARCH_LOG( "Asset copy successful.\n"); + } + } + + // create user data dirs + path_mkdir(g_defaults.dir.cheats); + path_mkdir(g_defaults.dir.menu_config); + path_mkdir(g_defaults.dir.menu_content); + path_mkdir(g_defaults.dir.core_assets); + path_mkdir(g_defaults.dir.playlist); + path_mkdir(g_defaults.dir.remap); + path_mkdir(g_defaults.dir.savestate); + path_mkdir(g_defaults.dir.screenshot); + path_mkdir(g_defaults.dir.sram); + path_mkdir(g_defaults.dir.system); + path_mkdir(g_defaults.dir.thumbnails); + + // set glui as default menu + snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "glui"); } enum frontend_architecture frontend_qnx_get_architecture(void) diff --git a/libretro-common/file/retro_stat.c b/libretro-common/file/retro_stat.c index 0cd7fd9a4b..d865f68e82 100644 --- a/libretro-common/file/retro_stat.c +++ b/libretro-common/file/retro_stat.c @@ -196,6 +196,8 @@ bool mkdir_norecurse(const char *dir) ret = mkdir(dir, 0755); #elif defined(VITA) || defined(PSP) ret = sceIoMkdir(dir, 0777); +#elif defined(__QNX__) + ret = mkdir(dir, 0777); #else ret = mkdir(dir, 0750); #endif