void Ui_MainWindow::_open_bubble(int drv, const QString fname) { char path_shadow[PATH_MAX]; int i; if(fname.length() <= 0) return; drv = drv & 7; strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX); UPDATE_HISTORY(path_shadow, config.recent_bubble_casette_path[drv], listBubbles[drv]); get_parent_dir(path_shadow); strcpy(config.initial_bubble_casette_dir, path_shadow); // Update List strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX); if(emu) { emit sig_close_bubble(drv); //emu->LockVM(); emit sig_open_bubble(drv, fname, 0); menu_bubbles[drv]->do_update_histories(listBubbles[drv]); menu_bubbles[drv]->do_set_initialize_directory(config.initial_bubble_casette_dir); if(check_file_extension(path_shadow, ".b77")) { UPDATE_B77_LIST(drv, listB77[drv]); menu_bubbles[drv]->do_update_inner_media_bubble(listB77[drv], 0); } else { menu_bubbles[drv]->do_clear_inner_media(); } } }
int Ui_MainWindow::set_recent_bubble(int drv, int num) { QString s_path; char path_shadow[PATH_MAX]; int i; if((num < 0) || (num >= MAX_HISTORY)) return -1; s_path = QString::fromLocal8Bit(config.recent_bubble_casette_path[drv][num]); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); UPDATE_HISTORY(path_shadow, config.recent_bubble_casette_path[drv], listBubbles[drv]); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); get_parent_dir(path_shadow); strcpy(config.initial_bubble_casette_dir, path_shadow); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); if(emu) { emit sig_close_bubble(drv); emit sig_open_bubble(drv, s_path, 0); menu_bubbles[drv]->do_update_histories(listBubbles[drv]); menu_bubbles[drv]->do_set_initialize_directory(config.initial_bubble_casette_dir); if(check_file_extension(path_shadow, ".b77")) { UPDATE_B77_LIST(drv, listB77[drv]); menu_bubbles[drv]->do_update_inner_media_bubble(listB77[drv], 0); } else { menu_bubbles[drv]->do_clear_inner_media(); } } return 0; }
int Ui_MainWindow::set_recent_disk(int drv, int num) { QString s_path; char path_shadow[PATH_MAX]; int i; if((num < 0) || (num >= MAX_HISTORY)) return -1; s_path = QString::fromLocal8Bit(config.recent_floppy_disk_path[drv][num]); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); UPDATE_HISTORY(path_shadow, config.recent_floppy_disk_path[drv], listFDs[drv]); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); get_parent_dir(path_shadow); strcpy(config.initial_floppy_disk_dir, path_shadow); strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); if(emu) { emit sig_close_disk(drv); emit sig_open_disk(drv, s_path, 0); menu_fds[drv]->do_update_histories(listFDs[drv]); menu_fds[drv]->do_set_initialize_directory(config.initial_floppy_disk_dir); if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { UPDATE_D88_LIST(drv, listD88[drv]); menu_fds[drv]->do_update_inner_media(listD88[drv], 0); } else { menu_fds[drv]->do_clear_inner_media(); } if(using_flags->get_max_drive() >= 2) { strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX); if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { if(((drv & 1) == 0) && (drv + 1 < using_flags->get_max_drive()) && (1 < emu->d88_file[drv].bank_num)) { int drv2 = drv + 1; emit sig_close_disk(drv2); emit sig_open_disk(drv2, s_path, 1); menu_fds[drv2]->do_update_histories(listFDs[drv2]); menu_fds[drv2]->do_set_initialize_directory(config.initial_floppy_disk_dir); UPDATE_D88_LIST(drv2, listD88[drv2]); menu_fds[drv2]->do_update_inner_media(listD88[drv2], 1); } } } } return 0; }
void Ui_MainWindow::_open_disk(int drv, const QString fname) { char path_shadow[PATH_MAX]; int i; if(fname.length() <= 0) return; drv = drv & 7; strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX); UPDATE_HISTORY(path_shadow, config.recent_floppy_disk_path[drv], listFDs[drv]); get_parent_dir(path_shadow); strcpy(config.initial_floppy_disk_dir, path_shadow); // Update List strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX); if(emu) { emit sig_close_disk(drv); //emu->LockVM(); emit sig_open_disk(drv, fname, 0); menu_fds[drv]->do_update_histories(listFDs[drv]); menu_fds[drv]->do_set_initialize_directory(config.initial_floppy_disk_dir); if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { UPDATE_D88_LIST(drv, listD88[drv]); menu_fds[drv]->do_update_inner_media(listD88[drv], 0); } else { menu_fds[drv]->do_clear_inner_media(); } } if(using_flags->get_max_drive() >= 2) { if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { if(((drv & 1) == 0) && (drv + 1 < using_flags->get_max_drive()) && (1 < emu->d88_file[drv].bank_num)) { int drv2 = drv + 1; emit sig_close_disk(drv2); //emu->LockVM(); strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX); emit sig_open_disk(drv2, fname, 1); menu_fds[drv2]->do_update_histories(listFDs[drv2]); menu_fds[drv2]->do_set_initialize_directory(config.initial_floppy_disk_dir); UPDATE_D88_LIST(drv2, listD88[drv2]); menu_fds[drv2]->do_update_inner_media(listD88[drv2], 1); } } } }
/* Try to open a file for reading. If the filename ends in one of the defined compressor extensions, pipe the file through the decompressor */ struct timidity_file *try_to_open(char *name, int decompress) { struct timidity_file *tf; URL url; int len; if((url = url_arc_open(name)) == NULL) if((url = url_open(name)) == NULL) return NULL; tf = (struct timidity_file *)safe_malloc(sizeof(struct timidity_file)); tf->url = url; tf->tmpname = NULL; len = strlen(name); if(decompress && len >= 3 && strcasecmp(name + len - 3, ".gz") == 0) { int method; if(!IS_URL_SEEK_SAFE(tf->url)) { if((tf->url = url_cache_open(tf->url, 1)) == NULL) { close_file(tf); return NULL; } } method = skip_gzip_header(tf->url); if(method == ARCHIVEC_DEFLATED) { url_cache_disable(tf->url); if((tf->url = url_inflate_open(tf->url, -1, 1)) == NULL) { close_file(tf); return NULL; } /* success */ return tf; } /* fail */ url_rewind(tf->url); url_cache_disable(tf->url); } #ifdef __W32__ /* Sorry, DECOMPRESSOR_LIST and PATCH_CONVERTERS are not worked yet. */ return tf; #endif /* __W32__ */ #if defined(DECOMPRESSOR_LIST) if(decompress) { static char *decompressor_list[] = DECOMPRESSOR_LIST, **dec; char tmp[1024]; /* Check if it's a compressed file */ for(dec = decompressor_list; *dec; dec += 2) { if(!check_file_extension(name, *dec, 0)) continue; tf->tmpname = url_dumpfile(tf->url, *dec); if (tf->tmpname == NULL) { close_file(tf); return NULL; } url_close(tf->url); snprintf(tmp, sizeof(tmp), *(dec+1), tf->tmpname); if((tf->url = url_pipe_open(tmp)) == NULL) { close_file(tf); return NULL; } break; } } #endif /* DECOMPRESSOR_LIST */ #if defined(PATCH_CONVERTERS) if(decompress == 2) { static char *decompressor_list[] = PATCH_CONVERTERS, **dec; char tmp[1024]; /* Check if it's a compressed file */ for(dec = decompressor_list; *dec; dec += 2) { if(!check_file_extension(name, *dec, 0)) continue; tf->tmpname = url_dumpfile(tf->url, *dec); if (tf->tmpname == NULL) { close_file(tf); return NULL; } url_close(tf->url); sprintf(tmp, *(dec+1), tf->tmpname); if((tf->url = url_pipe_open(tmp)) == NULL) { close_file(tf); return NULL; } break; } } #endif /* PATCH_CONVERTERS */ return tf; }