src/mess/filemngr.c
| r2891 | r2892 | |
| 719 | 719 | ***************************************************************************/ |
| 720 | 720 | |
| 721 | 721 | /*------------------------------------------------- |
| 722 | fix_working_directory - checks the working |
| 723 | directory for this device to ensure that it |
| 724 | "makes sense" |
| 725 | -------------------------------------------------*/ |
| 726 | |
| 727 | static void fix_working_directory(const device_config *device) |
| 728 | { |
| 729 | /* if the image exists, set the working directory to the parent directory */ |
| 730 | if (image_exists(device)) |
| 731 | { |
| 732 | astring *astr = astring_alloc(); |
| 733 | zippath_parent(astr, image_filename(selected_device)); |
| 734 | image_set_working_directory(device, astring_c(astr)); |
| 735 | astring_free(astr); |
| 736 | } |
| 737 | |
| 738 | /* check to see if the path exists; if not clear it */ |
| 739 | if (check_path(image_working_directory(device)) != FILERR_NONE) |
| 740 | image_set_working_directory(device, NULL); |
| 741 | } |
| 742 | |
| 743 | |
| 744 | |
| 745 | /*------------------------------------------------- |
| 722 | 746 | file_manager_render_extra - perform our |
| 723 | 747 | special rendering |
| 724 | 748 | -------------------------------------------------*/ |
| r2891 | r2892 | |
| 814 | 838 | { |
| 815 | 839 | if (selected_absolute_index >= 0) |
| 816 | 840 | { |
| 841 | /* ensure that the working directory for this device exists */ |
| 842 | fix_working_directory(selected_device); |
| 843 | |
| 817 | 844 | /* set up current_directory and current_file - depends on whether we have an image */ |
| 818 | | if (image_exists(selected_device)) |
| 819 | | { |
| 820 | | /* note that we _should_ be able to use image_working_directory(); please fix */ |
| 821 | | current_directory = zippath_parent(astring_alloc(), image_filename(selected_device)); |
| 822 | | current_file = astring_cpyc(astring_alloc(), image_basename(selected_device)); |
| 823 | | } |
| 824 | | else |
| 825 | | { |
| 826 | | current_directory = astring_cpyc(astring_alloc(), image_working_directory(selected_device)); |
| 827 | | current_file = astring_cpyc(astring_alloc(), ""); |
| 828 | | } |
| 845 | current_directory = astring_cpyc(astring_alloc(), image_working_directory(selected_device)); |
| 846 | current_file = astring_cpyc(astring_alloc(), |
| 847 | image_exists(selected_device) ? image_basename(selected_device) : ""); |
| 829 | 848 | |
| 830 | 849 | memset(&fs_state, 0, sizeof(fs_state)); |
| 831 | 850 | return ui_menu_stack_push(menu_file_selector, fs_state.i); |