Merge pull request #163 from atmaxinger/fix-devpollcdrom

Mac GUI: don't show /dev/poll/cdrom if it is configured as cdrom
This commit is contained in:
asvitkine 2018-02-25 12:51:13 -05:00 committed by GitHub
commit 2e302d60a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 8 deletions

View File

@ -120,11 +120,14 @@ static NSString *getStringFromPrefs(const char *key)
/* Fetch all CDROMs */
index = 0;
while ((dsk = PrefsFindString("cdrom", index++)) != NULL) {
DiskType *disk = [[[DiskType alloc] init] autorelease];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:YES];
NSString *path = [NSString stringWithUTF8String: dsk ];
if (![path hasPrefix:@"/dev/"]) {
DiskType *disk = [[[DiskType alloc] init] autorelease];
[disk setPath:[NSString stringWithUTF8String: dsk ]];
[disk setIsCDROM:YES];
[diskArray addObject:disk];
[diskArray addObject:disk];
}
}
[disks setDataSource: self];
@ -403,10 +406,19 @@ static NSString *makeRelativeIfNecessary(NSString *path)
// Remove all disks
while (PrefsFindString("disk"))
PrefsRemoveItem("disk");
// Remove all cdroms
while (PrefsFindString("cdrom"))
PrefsRemoveItem("cdrom");
// Remove all cdroms (but keep the ones in /dev/)
const char *path;
int index = 0;
while ((path = PrefsFindString("cdrom", index)) != NULL) {
NSString *p = [NSString stringWithUTF8String: path];
if (![p hasPrefix:@"/dev/"]) {
PrefsRemoveItem("cdrom", index);
} else {
// only increase the index if the current entry has not been deleted
// if it has been deleted, the next entry is on the current entrys index
index++;
}
}
// Write all disks
for (int i = 0; i < [diskArray count]; i++) {