--- BasiliskII/src/MacOSX/sys_darwin.cpp 2004/01/26 11:11:33 1.4 +++ BasiliskII/src/MacOSX/sys_darwin.cpp 2005/01/30 21:42:13 1.7 @@ -1,5 +1,5 @@ /* - * $Id: sys_darwin.cpp,v 1.4 2004/01/26 11:11:33 nigel Exp $ + * $Id: sys_darwin.cpp,v 1.7 2005/01/30 21:42:13 gbeauche Exp $ * * sys_darwin.cpp - Extra Darwin system dependant routines. Called by: * @@ -7,7 +7,7 @@ * * Based on Apple's CDROMSample.c and Evan Jones' cd-discid.c patches * - * Basilisk II (C) 1997-2004 Christian Bauer + * Basilisk II (C) 1997-2005 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,9 @@ #import #import #import -#import +#ifdef MAC_OS_X_VERSION_10_2 + #import +#endif #import #import #import @@ -128,7 +130,7 @@ void DarwinAddCDROMPrefs(void) void DarwinAddFloppyPrefs(void) { mach_port_t masterPort; // The way to talk to the kernel - io_iterator_t allFloppies; // List of CD drives on the system + io_iterator_t allFloppies; // List of possible floppys CFMutableDictionaryRef classesToMatch; io_object_t nextFloppy; @@ -137,13 +139,17 @@ void DarwinAddFloppyPrefs(void) bug("IOMasterPort failed. Won't be able to do anything with floppy drives\n"); + // This selects all partitions of all disks classesToMatch = IOServiceMatching(kIOMediaClass); if ( classesToMatch ) { - // We acually want removables that are _not_ CDs, - // but I don't know how to do that yet. + // Skip drivers and partitions CFDictionarySetValue(classesToMatch, - CFSTR(kIOMediaRemovableKey), kCFBooleanTrue); + CFSTR(kIOMediaWholeKey), kCFBooleanTrue); + + // Skip fixed drives (hard disks?) + CFDictionarySetValue(classesToMatch, + CFSTR(kIOMediaEjectableKey), kCFBooleanTrue); } if ( IOServiceGetMatchingServices(masterPort, @@ -162,6 +168,26 @@ void DarwinAddFloppyPrefs(void) IORegistryEntryCreateCFProperty(nextFloppy, CFSTR(kIOBSDNameKey), kCFAllocatorDefault, 0); + long size; + CFTypeRef sizeAsCFNumber = + IORegistryEntryCreateCFProperty(nextFloppy, + CFSTR(kIOMediaSizeKey), + kCFAllocatorDefault, 0); + + if ( CFNumberGetValue((CFNumberRef)sizeAsCFNumber, + kCFNumberSInt32Type, &size) ) + { + D(bug("Got size of %ld\n", size)); + if ( size < 800 * 1024 || size > 1440 * 1024 ) + { + D(puts("Device does not appear to be 800k or 1440k")); + continue; + } + } + else + bug("Couldn't get kIOMediaSizeKey of device"); + + *bsdPath = '\0'; if ( bsdPathAsCFString ) {