--- BasiliskII/src/MacOSX/sys_darwin.cpp 2006/05/08 12:15:58 1.9 +++ BasiliskII/src/MacOSX/sys_darwin.cpp 2008/02/04 01:02:58 1.14 @@ -1,5 +1,5 @@ /* - * $Id: sys_darwin.cpp,v 1.9 2006/05/08 12:15:58 gbeauche Exp $ + * $Id: sys_darwin.cpp,v 1.14 2008/02/04 01:02:58 nigel 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-2005 Christian Bauer + * Basilisk II (C) 1997-2008 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 @@ -115,7 +115,7 @@ static kern_return_t get_device_path(io_ static void media_arrived(int type, io_iterator_t iterator) { io_object_t obj; - while ((obj = IOIteratorNext(iterator)) != NULL) { + while ((obj = IOIteratorNext(iterator))) { char path[MAXPATHLEN]; kern_return_t kernResult = get_device_path(obj, path, sizeof(path)); if (kernResult == KERN_SUCCESS) { @@ -137,7 +137,7 @@ static void media_arrived(int type, io_i static void media_removed(int type, io_iterator_t iterator) { io_object_t obj; - while ((obj = IOIteratorNext(iterator)) != NULL) { + while ((obj = IOIteratorNext(iterator))) { char path[MAXPATHLEN]; kern_return_t kernResult = get_device_path(obj, path, sizeof(path)); if (kernResult == KERN_SUCCESS) { @@ -236,15 +236,10 @@ void DarwinAddFloppyPrefs(void) return; } - // Iterate through each floppy while ( nextFloppy = IOIteratorNext(allFloppies)) { char bsdPath[MAXPATHLEN]; - CFTypeRef bsdPathAsCFString = - IORegistryEntryCreateCFProperty(nextFloppy, - CFSTR(kIOBSDNameKey), - kCFAllocatorDefault, 0); long size; CFTypeRef sizeAsCFNumber = IORegistryEntryCreateCFProperty(nextFloppy, @@ -261,33 +256,16 @@ void DarwinAddFloppyPrefs(void) continue; } } - else - bug("Couldn't get kIOMediaSizeKey of device"); - - - *bsdPath = '\0'; - if ( bsdPathAsCFString ) - { - size_t devPathLength; - - strcpy(bsdPath, "/dev/"); - devPathLength = strlen(bsdPath); - - if ( CFStringGetCString((const __CFString *)bsdPathAsCFString, - bsdPath + devPathLength, - MAXPATHLEN - devPathLength, - kCFStringEncodingASCII) ) - { - D(bug("Floppy BSD path: %s\n", bsdPath)); - PrefsAddString("floppy", bsdPath); - } - else - D(bug("Could not get BSD device path for floppy\n")); + else { + D(puts("Couldn't get kIOMediaSizeKey of device")); + continue; // if kIOMediaSizeKey is unavailable, we shouldn't use it anyway + } - CFRelease(bsdPathAsCFString); + if (get_device_path(nextFloppy, bsdPath, sizeof(bsdPath)) == KERN_SUCCESS) { + PrefsAddString("floppy", bsdPath); + } else { + D(bug("Could not get BSD device path for floppy\n")); } - else - D(bug("Cannot determine bsdPath for floppy\n")); } IOObjectRelease(nextFloppy);