mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-27 02:49:42 +00:00
drop and mount
This commit is contained in:
parent
6f94fdd7b0
commit
a94a41885b
@ -68,6 +68,7 @@
|
||||
#include "video_defs.h"
|
||||
#include "video_blit.h"
|
||||
#include "vm_alloc.h"
|
||||
#include "cdrom.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -2412,6 +2413,11 @@ static void handle_events(void)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_DROPFILE:
|
||||
CDROMDrop(event.drop.file);
|
||||
SDL_free(event.drop.file);
|
||||
break;
|
||||
|
||||
// Window "close" widget clicked
|
||||
case SDL_QUIT:
|
||||
if (SDL_GetModState() & (KMOD_LALT | KMOD_RALT)) break;
|
||||
|
@ -540,14 +540,14 @@ static mac_file_handle *open_filehandle(const char *name)
|
||||
return fh;
|
||||
}
|
||||
|
||||
void *Sys_open(const char *name, bool read_only)
|
||||
void *Sys_open(const char *name, bool read_only, bool is_cdrom)
|
||||
{
|
||||
bool is_file = strncmp(name, "/dev/", 5) != 0;
|
||||
#if defined(__FreeBSD__)
|
||||
// SCSI IDE
|
||||
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0 || strncmp(name, "/dev/acd", 8) == 0;
|
||||
is_cdrom |= strncmp(name, "/dev/cd", 7) == 0 || strncmp(name, "/dev/acd", 8) == 0;
|
||||
#else
|
||||
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0;
|
||||
is_cdrom |= strncmp(name, "/dev/cd", 7) == 0;
|
||||
#endif
|
||||
bool is_floppy = strncmp(name, "/dev/fd", 7) == 0;
|
||||
|
||||
|
@ -446,7 +446,7 @@ static bool is_read_only_path(const TCHAR *name)
|
||||
* Open file/device, create new file handle (returns NULL on error)
|
||||
*/
|
||||
|
||||
void *Sys_open(const char *path_name, bool read_only)
|
||||
void *Sys_open(const char *path_name, bool read_only, bool is_cdrom)
|
||||
{
|
||||
file_handle * fh = NULL;
|
||||
|
||||
|
@ -301,16 +301,13 @@ static bool position2msf(const cdrom_drive_info &info, uint16 postype, uint32 po
|
||||
|
||||
void CDROMInit(void)
|
||||
{
|
||||
// No drives specified in prefs? Then add defaults
|
||||
if (PrefsFindString("cdrom", 0) == NULL) {
|
||||
SysAddCDROMPrefs();
|
||||
}
|
||||
SysAddCDROMPrefs();
|
||||
|
||||
// Add drives specified in preferences
|
||||
int index = 0;
|
||||
const char *str;
|
||||
while ((str = PrefsFindString("cdrom", index++)) != NULL) {
|
||||
void *fh = Sys_open(str, true);
|
||||
void *fh = Sys_open(str, true, true);
|
||||
if (fh)
|
||||
drives.push_back(cdrom_drive_info(fh));
|
||||
}
|
||||
@ -323,6 +320,10 @@ void CDROMInit(void)
|
||||
}
|
||||
}
|
||||
|
||||
void CDROMDrop(const char *path) {
|
||||
if (!drives.empty())
|
||||
drives.front().fh = Sys_open(path, true, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Deinitialization
|
||||
@ -564,6 +565,8 @@ int16 CDROMControl(uint32 pb, uint32 dce)
|
||||
SysEject(info->fh);
|
||||
WriteMacInt8(info->status + dsDiskInPlace, 0);
|
||||
info->twok_offset = -1;
|
||||
info->close_fh();
|
||||
info->fh = NULL;
|
||||
return noErr;
|
||||
} else {
|
||||
return offLinErr;
|
||||
|
@ -42,4 +42,6 @@ extern int16 CDROMStatus(uint32 pb, uint32 dce);
|
||||
|
||||
extern void CDROMOpenDone(void); // Called by CDROMOpen() once drives have been to the drive queue
|
||||
|
||||
void CDROMDrop(const char *path);
|
||||
|
||||
#endif
|
||||
|
@ -50,7 +50,7 @@ extern void SysAddSerialPrefs(void);
|
||||
* that is freed by Sys_close().
|
||||
*/
|
||||
|
||||
extern void *Sys_open(const char *name, bool read_only);
|
||||
extern void *Sys_open(const char *name, bool read_only, bool is_cdrom = false);
|
||||
extern void Sys_close(void *fh);
|
||||
extern size_t Sys_read(void *fh, void *buffer, loff_t offset, size_t length);
|
||||
extern size_t Sys_write(void *fh, void *buffer, loff_t offset, size_t length);
|
||||
|
Loading…
Reference in New Issue
Block a user