/* Same for Win32 */ #if defined(__WIN32__) static void init_win32_paths(void) { HMODULE hModule; DWORD dWord; char *sBuffer; gchar *dirname; gchar *basename; // Init the path for the Windows version by getting the // executable location. hModule = GetModuleHandle("tiemu.exe"); sBuffer = (char *) malloc(4096 * sizeof(char)); dWord = GetModuleFileName(hModule, sBuffer, 4096); dirname = g_path_get_dirname(sBuffer); basename = g_path_get_basename(dirname); // modify exec path like '/target/bin' into '/target/share/tiemu' if we // are running an Msys path (MinGW). Otherwise, do nothing if we are running from a // local path (MSVC & InnoSetup) if((strlen(basename) == 3) && !g_strcasecmp(basename, "bin")) { gchar *token; dirname = g_realloc(dirname, strlen(dirname) + strlen(MINGW_REL) + 1); token = dirname + strlen(dirname) - 3; strcpy(token, MINGW_REL); } // set base dir inst_paths.base_dir = g_strconcat(dirname, "\\", NULL); free(sBuffer); // malloc -> free g_free(dirname); g_free(basename); // set others inst_paths.pixmap_dir = g_strconcat(inst_paths.base_dir, "pixmaps\\", NULL); inst_paths.help_dir = g_strconcat(inst_paths.base_dir, "help\\", NULL); inst_paths.manpage_dir = g_strconcat(inst_paths.base_dir, "", NULL); inst_paths.skin_dir = g_strconcat(inst_paths.base_dir, "skins\\", NULL); inst_paths.glade_dir = g_strconcat(inst_paths.base_dir, "glade\\", NULL); inst_paths.home_dir = g_strconcat(inst_paths.base_dir, "", NULL); inst_paths.img_dir = g_strconcat(inst_paths.home_dir, CONF_DIR, "images\\", NULL); _mkdir(inst_paths.img_dir); inst_paths.rom_dir = g_strconcat(inst_paths.base_dir, "pedrom\\", NULL); #ifdef ENABLE_NLS inst_paths.locale_dir = g_strconcat(inst_paths.base_dir, "locale\\", NULL); #endif /* */ // on WIN32 systems, local by default _chdir(inst_paths.home_dir); } #endif /* */ int initialize_paths(void) { #ifdef __WIN32__ init_win32_paths(); #else init_linux_paths(); #endif return 0; }
int tilp_paths_init(void) { #if defined(__LINUX__) || defined(__BSD__) || defined(__MACOSX__) init_linux_paths(); #elif defined(__WIN32__) init_win32_paths(); #endif /* */ return 0; }