void mon_drive_list(int drive_number) { const char *name; image_contents_t *listing; vdrive_t *vdrive; if ((drive_number < 8) || (drive_number > 11)) { drive_number = 8; } vdrive = file_system_get_vdrive(drive_number); if (vdrive == NULL || vdrive->image == NULL) { mon_out("Drive %i not ready.\n", drive_number); return; } name = disk_image_name_get(vdrive->image); listing = diskcontents_read(name, drive_number); if (listing != NULL) { char *string = image_contents_to_string(listing, 1); image_contents_file_list_t *element = listing->file_list; mon_out("%s\n", string); lib_free(string); if (element == NULL) { mon_out("Empty image\n"); } else { do { string = image_contents_file_to_string(element, 1); mon_out("%s\n", string); lib_free(string); } while ((element = element->next) != NULL); } if (listing->blocks_free >= 0) { string = lib_msprintf("%d blocks free.\n", listing->blocks_free); mon_out("%s", string); lib_free(string); } } }
static void sdl_ui_image_file_selector_redraw(image_contents_t *contents, const char *title, int offset, int num_items, int more, ui_menu_filereq_mode_t mode, int cur_offset) { int i, j; char* title_string; char* name; uint8_t oldbg; image_contents_file_list_t *entry; title_string = image_contents_to_string(contents, 0); sdl_ui_clear(); sdl_ui_display_title(title_string); lib_free(title_string); entry = contents->file_list; for (i = 0; i < offset; ++i) { entry = entry->next; } for (i = 0; i < num_items; ++i) { if (i == cur_offset) { oldbg = sdl_ui_set_cursor_colors(); } j = MENU_FIRST_X; name = image_contents_file_to_string(entry, IMAGE_CONTENTS_STRING_PETSCII); j += sdl_ui_print(name, j, i + IMAGE_FIRST_Y + SDL_FILEREQ_META_NUM); if (i == cur_offset) { sdl_ui_print_eol(j, i + IMAGE_FIRST_Y + SDL_FILEREQ_META_NUM); sdl_ui_reset_cursor_colors(oldbg); } entry = entry->next; } name = lib_msprintf("%d BLOCKS FREE.", contents->blocks_free); sdl_ui_print(name, MENU_FIRST_X, i + IMAGE_FIRST_Y + SDL_FILEREQ_META_NUM); lib_free(name); }