src/mess/filemngr.c
| r2965 | r2966 | |
| 39 | 39 | typedef struct _file_manager_menu_state file_manager_menu_state; |
| 40 | 40 | struct _file_manager_menu_state |
| 41 | 41 | { |
| 42 | | object_pool *pool; |
| 43 | 42 | const device_config *selected_device; |
| 44 | 43 | astring *current_directory; |
| 45 | 44 | astring *current_file; |
| r2965 | r2966 | |
| 71 | 70 | ***************************************************************************/ |
| 72 | 71 | |
| 73 | 72 | /*------------------------------------------------- |
| 74 | | memory_error - report a memory error |
| 75 | | -------------------------------------------------*/ |
| 76 | | |
| 77 | | static void memory_error(const char *message) |
| 78 | | { |
| 79 | | fatalerror("%s", message); |
| 80 | | } |
| 81 | | |
| 82 | | |
| 83 | | |
| 84 | | /*------------------------------------------------- |
| 85 | 73 | code_to_ascii - converts an input_code to its |
| 86 | 74 | ASCII equivalent |
| 87 | 75 | -------------------------------------------------*/ |
| r2965 | r2966 | |
| 398 | 386 | of type osd_directory_entry |
| 399 | 387 | -------------------------------------------------*/ |
| 400 | 388 | |
| 401 | | static osd_directory_entry *alloc_directory_entry(object_pool *pool, const char *name, osd_dir_entry_type type, UINT64 size) |
| 389 | static osd_directory_entry *alloc_directory_entry(ui_menu *menu, const char *name, osd_dir_entry_type type, UINT64 size) |
| 402 | 390 | { |
| 403 | 391 | char *name_dupe = NULL; |
| 404 | 392 | osd_directory_entry *new_entry; |
| r2965 | r2966 | |
| 406 | 394 | |
| 407 | 395 | /* allocate the new entry */ |
| 408 | 396 | name_length = (name != NULL) ? strlen(name) + 1 : 0; |
| 409 | | new_entry = pool_malloc(pool, sizeof(*new_entry) + name_length); |
| 397 | new_entry = ui_menu_pool_alloc(menu, sizeof(*new_entry) + name_length); |
| 410 | 398 | |
| 411 | 399 | /* copy the name, if specified */ |
| 412 | 400 | if (name != NULL) |
| r2965 | r2966 | |
| 452 | 440 | |
| 453 | 441 | if (dirent_size != ~0) |
| 454 | 442 | { |
| 455 | | new_dirent = alloc_directory_entry(menustate->manager_menustate->pool, dirent_name, dirent_type, dirent_size); |
| 443 | new_dirent = alloc_directory_entry(menu, dirent_name, dirent_type, dirent_size); |
| 456 | 444 | |
| 457 | 445 | /* silly hack */ |
| 458 | 446 | if (text == dirent_name) |
| r2965 | r2966 | |
| 764 | 752 | astring_free(menustate->current_file); |
| 765 | 753 | menustate->current_file = NULL; |
| 766 | 754 | } |
| 767 | | if (menustate->pool != NULL) |
| 768 | | { |
| 769 | | pool_free(menustate->pool); |
| 770 | | menustate->pool = NULL; |
| 771 | | } |
| 772 | 755 | |
| 773 | 756 | /* if the menu isn't built, populate now */ |
| 774 | 757 | if (!ui_menu_populated(menu)) |
| r2965 | r2966 | |
| 789 | 772 | menustate->current_file = astring_cpyc(astring_alloc(), |
| 790 | 773 | image_exists(menustate->selected_device) ? image_basename(menustate->selected_device) : ""); |
| 791 | 774 | |
| 792 | | /* create a memory pool */ |
| 793 | | menustate->pool = pool_alloc(memory_error); |
| 794 | | |
| 795 | 775 | /* push the menu */ |
| 796 | 776 | child_menu = ui_menu_alloc(machine, menu_file_selector, NULL); |
| 797 | 777 | child_menustate = ui_menu_alloc_state(child_menu, sizeof(*child_menustate)); |