src/osd/sdl/sdlos_win32.c
| r7343 | r7344 | |
| 548 | 548 | free(t_path); |
| 549 | 549 | return err; |
| 550 | 550 | } |
| 551 | | |
| 552 | | //============================================================ |
| 553 | | // win_get_module_file_name_utf8 |
| 554 | | //============================================================ |
| 555 | | |
| 556 | | static DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size) |
| 557 | | { |
| 558 | | TCHAR t_filename[MAX_PATH]; |
| 559 | | char *utf8_filename; |
| 560 | | |
| 561 | | if (GetModuleFileName(module, t_filename, ARRAY_LENGTH(t_filename)) == 0) |
| 562 | | return 0; |
| 563 | | |
| 564 | | utf8_filename = utf8_from_tstring(t_filename); |
| 565 | | if (!utf8_filename) |
| 566 | | return 0; |
| 567 | | |
| 568 | | size = (DWORD) snprintf(filename, size, "%s", utf8_filename); |
| 569 | | free(utf8_filename); |
| 570 | | return size; |
| 571 | | } |
| 572 | | |
| 573 | | //============================================================ |
| 574 | | // osd_get_emulator_directory |
| 575 | | //============================================================ |
| 576 | | |
| 577 | | void osd_get_emulator_directory(char *dir, size_t dir_size) |
| 578 | | { |
| 579 | | char *s; |
| 580 | | win_get_module_file_name_utf8(NULL, dir, dir_size); |
| 581 | | s = strrchr(dir, '\\'); |
| 582 | | if (s) |
| 583 | | s[1] = '\0'; |
| 584 | | } |
| | No newline at end of file |
src/osd/osdcore.h
| r7343 | r7344 | |
| 834 | 834 | ***************************************************************************/ |
| 835 | 835 | |
| 836 | 836 | /*----------------------------------------------------------------------------- |
| 837 | | osd_get_emulator_directory: returns the path containing the emulator |
| 838 | | |
| 839 | | Parameters: |
| 840 | | |
| 841 | | dir - space to output directory |
| 842 | | dir_size - size of path |
| 843 | | |
| 844 | | -----------------------------------------------------------------------------*/ |
| 845 | | |
| 846 | | void osd_get_emulator_directory(char *dir, size_t dir_size); |
| 847 | | |
| 848 | | /*----------------------------------------------------------------------------- |
| 849 | 837 | osd_get_full_path: retrieves the full path |
| 850 | 838 | |
| 851 | 839 | Parameters: |
src/mess/image.c
| r7343 | r7344 | |
| 1636 | 1636 | |
| 1637 | 1637 | static void setup_working_directory(image_slot_data *image) |
| 1638 | 1638 | { |
| 1639 | | char mess_directory[1024]; |
| 1640 | 1639 | const game_driver *gamedrv; |
| 1641 | 1640 | |
| 1642 | 1641 | /* first set up the working directory to be the MESS directory */ |
| 1643 | | osd_get_emulator_directory(mess_directory, ARRAY_LENGTH(mess_directory)); |
| 1644 | | astring_cpyc(image->working_directory, mess_directory); |
| 1642 | astring_cpyc(image->working_directory, "."); |
| 1645 | 1643 | |
| 1646 | 1644 | /* now try browsing down to "software" */ |
| 1647 | 1645 | if (try_change_working_directory(image, "software")) |
src/mess/osd/winui/messui.c
| r7343 | r7344 | |
| 927 | 927 | if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1)) |
| 928 | 928 | { |
| 929 | 929 | /* Default to emu directory */ |
| 930 | | char mess_directory[1024]; |
| 931 | | osd_get_emulator_directory(mess_directory, ARRAY_LENGTH(mess_directory)); |
| 932 | | s = tstring_from_utf8(mess_directory); |
| 930 | s = tstring_from_utf8("."); |
| 933 | 931 | |
| 934 | 932 | /* If software folder exists, use it instead */ |
| 935 | | zippath_combine(&as, mess_directory, "software"); |
| 933 | zippath_combine(&as, ".", "software"); |
| 936 | 934 | if (osd_opendir(astring_c(&as))) s = tstring_from_utf8(astring_c(&as)); |
| 937 | 935 | } |
| 938 | 936 | } |
| r7343 | r7344 | |
| 987 | 985 | if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1)) |
| 988 | 986 | { |
| 989 | 987 | /* Default to emu directory */ |
| 990 | | char mess_directory[1024]; |
| 991 | | osd_get_emulator_directory(mess_directory, ARRAY_LENGTH(mess_directory)); |
| 992 | | s = tstring_from_utf8(mess_directory); |
| 988 | s = tstring_from_utf8("."); |
| 993 | 989 | |
| 994 | 990 | /* If software folder exists, use it instead */ |
| 995 | | zippath_combine(&as, mess_directory, "software"); |
| 991 | zippath_combine(&as, ".", "software"); |
| 996 | 992 | if (osd_opendir(astring_c(&as))) s = tstring_from_utf8(astring_c(&as)); |
| 997 | 993 | } |
| 998 | 994 | } |