From: Holger Schemel Date: Sat, 14 Jan 2017 15:41:14 +0000 (+0100) Subject: fixed determining program main data path for Mac OS X X-Git-Tag: 4.0.0.2~35 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=378017ef8970cd08f0aa9cc2855eb4233f5a23a6;p=rocksndiamonds.git fixed determining program main data path for Mac OS X --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 4ffb51c7..bd069f92 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -709,11 +709,19 @@ static char *getProgramMainDataPath() char *main_data_path_old = main_data_path; // cut relative path to Mac OS X application binary directory from path - main_data_path_old[strlen(main_data_path_old) - - strlen(main_data_binary_subdir)] = '\0'; + main_data_path[strlen(main_data_path) - + strlen(main_data_binary_subdir)] = '\0'; + + // cut trailing path separator from path (but not if path is root directory) + if (strSuffix(main_data_path, "/") && !strEqual(main_data_path, "/")) + main_data_path[strlen(main_data_path) - 1] = '\0'; + + // replace empty path with current directory + if (strEqual(main_data_path, "")) + main_data_path = "."; // add relative path to Mac OS X application resources directory to path - main_data_path = getPath2(main_data_path_old, main_data_files_subdir); + main_data_path = getPath2(main_data_path, main_data_files_subdir); free(main_data_path_old); }