int autostart_prg_with_virtual_fs(const char *file_name, fileio_info_t *fh) { char *directory; char *file; /* Extract the directory path to allow FS-based drive emulation to work. */ util_fname_split(file_name, &directory, &file); if (archdep_path_is_relative(directory)) { char *tmp; archdep_expand_path(&tmp, directory); lib_free(directory); directory = tmp; /* FIXME: We should actually eat `.'s and `..'s from `directory' instead. */ } /* Setup FS-based drive emulation. */ fsdevice_set_directory(directory ? directory : ".", 8); resources_set_int("DriveTrueEmulation", 0); resources_set_int("VirtualDevices", 1); resources_set_int("FSDevice8ConvertP00", 1); file_system_detach_disk(8); resources_set_int("FileSystemDevice8", ATTACH_DEVICE_FS); lib_free(directory); lib_free(file); return 0; }
/* Autostart PRG file `file_name'. The PRG file can either be a raw CBM file or a P00 file, and the FS-based drive emulation is set up so that its directory becomes the current one on unit #8. */ int autostart_prg(const char *file_name, unsigned int runmode) { char *directory; char *file; fileio_info_t *finfo; if (network_connected()) return -1; finfo = fileio_open(file_name, NULL, FILEIO_FORMAT_RAW | FILEIO_FORMAT_P00, FILEIO_COMMAND_READ | FILEIO_COMMAND_FSNAME, FILEIO_TYPE_PRG); if (finfo == NULL) { log_error(autostart_log, "Cannot open `%s'.", file_name); return -1; } /* Extract the directory path to allow FS-based drive emulation to work. */ util_fname_split(file_name, &directory, &file); if (archdep_path_is_relative(directory)) { char *tmp; archdep_expand_path(&tmp, directory); lib_free(directory); directory = tmp; /* FIXME: We should actually eat `.'s and `..'s from `directory' instead. */ } /* Setup FS-based drive emulation. */ fsdevice_set_directory(directory ? directory : ".", 8); set_true_drive_emulation_mode(0); orig_drive_true_emulation_state =0; resources_set_int("VirtualDevices", 1); resources_set_int("FSDevice8ConvertP00", 1); file_system_detach_disk(8); ui_update_menus(); /* Now it's the same as autostarting a disk image. */ reboot_for_autostart((char *)(finfo->name), AUTOSTART_HASDISK, runmode); lib_free(directory); lib_free(file); fileio_close(finfo); log_message(autostart_log, "Preparing to load PRG file `%s'.", file_name); return 0; }
static int fsdevice_flush_cd(vdrive_t* vdrive, char *arg) { int er; er = CBMDOS_IPE_OK; if (ioutil_chdir(fsdevice_get_path(vdrive->unit)) || ioutil_chdir(arg)) { er = CBMDOS_IPE_NOT_FOUND; if (ioutil_errno(IOUTIL_ERRNO_EPERM)) { er = CBMDOS_IPE_PERMISSION; } } else { /* get full path and save */ arg = ioutil_current_dir(); fsdevice_set_directory(arg, vdrive->unit); lib_free(arg); } return er; }