From 581ce7d971632cbb89e61cc842feb2be4d3969fc Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Tue, 20 Feb 2018 11:54:55 +0100 Subject: [PATCH 01/11] Mac GUI: don't show /dev/poll/cdrom if it is configured as cdrom --- .../src/MacOSX/Launcher/VMSettingsController.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index ceed49ff..3a69032b 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -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 isEqualToString:@"/dev/poll/cdrom"]) { + DiskType *disk = [[[DiskType alloc] init] autorelease]; + [disk setPath:[NSString stringWithUTF8String: dsk ]]; + [disk setIsCDROM:YES]; - [diskArray addObject:disk]; + [diskArray addObject:disk]; + } } [disks setDataSource: self]; From 3931036d87e5856224dea756da9c75f25c6601dd Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Tue, 20 Feb 2018 12:39:59 +0100 Subject: [PATCH 02/11] Fix whitespace --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 3a69032b..29c4c36c 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -121,7 +121,7 @@ static NSString *getStringFromPrefs(const char *key) index = 0; while ((dsk = PrefsFindString("cdrom", index++)) != NULL) { NSString *path = [NSString stringWithUTF8String: dsk ]; - if(![path isEqualToString:@"/dev/poll/cdrom"]) { + if (![path isEqualToString:@"/dev/poll/cdrom"]) { DiskType *disk = [[[DiskType alloc] init] autorelease]; [disk setPath:[NSString stringWithUTF8String: dsk ]]; [disk setIsCDROM:YES]; From 787661f80f10ccc76610644450ff7ae389cde9f2 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Wed, 21 Feb 2018 15:24:29 +0100 Subject: [PATCH 03/11] Always save the default entry "cdrom /dev/poll/cdrom" --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 29c4c36c..530bc302 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -51,6 +51,8 @@ void prefs_exit() } #endif +#define DEFAULT_CDROM_PATH "/dev/poll/cdrom" + @implementation VMSettingsController + (id) sharedInstance @@ -121,7 +123,7 @@ static NSString *getStringFromPrefs(const char *key) index = 0; while ((dsk = PrefsFindString("cdrom", index++)) != NULL) { NSString *path = [NSString stringWithUTF8String: dsk ]; - if (![path isEqualToString:@"/dev/poll/cdrom"]) { + if (![path isEqualToString:@DEFAULT_CDROM_PATH]) { DiskType *disk = [[[DiskType alloc] init] autorelease]; [disk setPath:[NSString stringWithUTF8String: dsk ]]; [disk setIsCDROM:YES]; @@ -417,6 +419,8 @@ static NSString *makeRelativeIfNecessary(NSString *path) PrefsAddString([d isCDROM] ? "cdrom" : "disk", [[d path] UTF8String]); } + PrefsAddString("cdrom", DEFAULT_CDROM_PATH); + PrefsReplaceInt32("bootdriver", ([bootFrom indexOfSelectedItem] == 1 ? CDROMRefNum : 0)); PrefsReplaceString("rom", [[romFile stringValue] UTF8String]); PrefsReplaceString("extfs", [[unixRoot stringValue] UTF8String]); From 85bcff03d42bd7c15a3c1695eb0492443d87ad69 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Wed, 21 Feb 2018 16:24:20 +0100 Subject: [PATCH 04/11] Block all CDROMs in /dev/ --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 530bc302..54546f5b 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -51,8 +51,6 @@ void prefs_exit() } #endif -#define DEFAULT_CDROM_PATH "/dev/poll/cdrom" - @implementation VMSettingsController + (id) sharedInstance @@ -123,7 +121,7 @@ static NSString *getStringFromPrefs(const char *key) index = 0; while ((dsk = PrefsFindString("cdrom", index++)) != NULL) { NSString *path = [NSString stringWithUTF8String: dsk ]; - if (![path isEqualToString:@DEFAULT_CDROM_PATH]) { + if (![path hasPrefix:@"/dev/"]) { DiskType *disk = [[[DiskType alloc] init] autorelease]; [disk setPath:[NSString stringWithUTF8String: dsk ]]; [disk setIsCDROM:YES]; @@ -419,8 +417,6 @@ static NSString *makeRelativeIfNecessary(NSString *path) PrefsAddString([d isCDROM] ? "cdrom" : "disk", [[d path] UTF8String]); } - PrefsAddString("cdrom", DEFAULT_CDROM_PATH); - PrefsReplaceInt32("bootdriver", ([bootFrom indexOfSelectedItem] == 1 ? CDROMRefNum : 0)); PrefsReplaceString("rom", [[romFile stringValue] UTF8String]); PrefsReplaceString("extfs", [[unixRoot stringValue] UTF8String]); From 4ba1c48ec84f481d0b9375e22d6bf60e56cb8dbb Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Thu, 22 Feb 2018 10:36:36 +0100 Subject: [PATCH 05/11] Always write /dev/poll/cdrom to preferences --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 54546f5b..8347c3a4 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -417,6 +417,8 @@ static NSString *makeRelativeIfNecessary(NSString *path) PrefsAddString([d isCDROM] ? "cdrom" : "disk", [[d path] UTF8String]); } + PrefsAddString("cdrom", "/dev/poll/cdrom"); + PrefsReplaceInt32("bootdriver", ([bootFrom indexOfSelectedItem] == 1 ? CDROMRefNum : 0)); PrefsReplaceString("rom", [[romFile stringValue] UTF8String]); PrefsReplaceString("extfs", [[unixRoot stringValue] UTF8String]); From f2fcfffabbde6914c32cdec95e4918896b396a3a Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Thu, 22 Feb 2018 11:11:11 +0100 Subject: [PATCH 06/11] Always save the cdrom entries from /dev/ --- .../src/MacOSX/Launcher/VMSettingsController.mm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 8347c3a4..f72ec39a 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -406,10 +406,15 @@ 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"); + } + } // Write all disks for (int i = 0; i < [diskArray count]; i++) { @@ -417,8 +422,6 @@ static NSString *makeRelativeIfNecessary(NSString *path) PrefsAddString([d isCDROM] ? "cdrom" : "disk", [[d path] UTF8String]); } - PrefsAddString("cdrom", "/dev/poll/cdrom"); - PrefsReplaceInt32("bootdriver", ([bootFrom indexOfSelectedItem] == 1 ? CDROMRefNum : 0)); PrefsReplaceString("rom", [[romFile stringValue] UTF8String]); PrefsReplaceString("extfs", [[unixRoot stringValue] UTF8String]); From 515746d584d7006fb3e3c62142f7872692e2b6e6 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Thu, 22 Feb 2018 11:32:57 +0100 Subject: [PATCH 07/11] Only remove item at index --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index f72ec39a..c1eafa13 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -409,11 +409,13 @@ static NSString *makeRelativeIfNecessary(NSString *path) // Remove all cdroms (but keep the ones in /dev/) const char *path; int index=0; - while ((path = PrefsFindString("cdrom", index++)) != NULL) { + while ((path = PrefsFindString("cdrom", index)) != NULL) { NSString *p = [NSString stringWithUTF8String: path]; if(![p hasPrefix:@"/dev/"]) { - PrefsRemoveItem("cdrom"); + PrefsRemoveItem("cdrom", index); } + + index++; } // Write all disks From f25821d067923316849d59fb1112a1acd13d3595 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Thu, 22 Feb 2018 23:06:23 +0100 Subject: [PATCH 08/11] Fix CD ROM entries appearing multiple times --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index c1eafa13..bd47a953 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -413,9 +413,12 @@ static NSString *makeRelativeIfNecessary(NSString *path) 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++; } - - index++; } // Write all disks From a2e163fea90cd0654d5c7c09d9bb1ea67192bb9c Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Thu, 22 Feb 2018 23:08:57 +0100 Subject: [PATCH 09/11] fix whitespaces --- .../src/MacOSX/Launcher/VMSettingsController.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index bd47a953..9281f7ab 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -414,11 +414,11 @@ static NSString *makeRelativeIfNecessary(NSString *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++; - } + 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 From 4f14c448372b6e8d68ce32284f42b93fce5f0c88 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Sun, 25 Feb 2018 17:01:12 +0100 Subject: [PATCH 10/11] Fix formatting --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 9281f7ab..46e5a9fb 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -121,7 +121,7 @@ static NSString *getStringFromPrefs(const char *key) index = 0; while ((dsk = PrefsFindString("cdrom", index++)) != NULL) { NSString *path = [NSString stringWithUTF8String: dsk ]; - if (![path hasPrefix:@"/dev/"]) { + if (![path hasPrefix:@"/dev/"]) { DiskType *disk = [[[DiskType alloc] init] autorelease]; [disk setPath:[NSString stringWithUTF8String: dsk ]]; [disk setIsCDROM:YES]; @@ -408,13 +408,12 @@ static NSString *makeRelativeIfNecessary(NSString *path) PrefsRemoveItem("disk"); // Remove all cdroms (but keep the ones in /dev/) const char *path; - int index=0; + int index = 0; while ((path = PrefsFindString("cdrom", index)) != NULL) { NSString *p = [NSString stringWithUTF8String: path]; - if(![p hasPrefix:@"/dev/"]) { + if (![p hasPrefix:@"/dev/"]) { PrefsRemoveItem("cdrom", index); - } - else { + } 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++; From e791a1fdd69a70e9240c4c2cb116cdeeb25e2ea1 Mon Sep 17 00:00:00 2001 From: atmaxinger Date: Sun, 25 Feb 2018 17:44:08 +0100 Subject: [PATCH 11/11] fix identation --- SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm index 46e5a9fb..a5319175 100755 --- a/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm +++ b/SheepShaver/src/MacOSX/Launcher/VMSettingsController.mm @@ -410,7 +410,7 @@ static NSString *makeRelativeIfNecessary(NSString *path) const char *path; int index = 0; while ((path = PrefsFindString("cdrom", index)) != NULL) { - NSString *p = [NSString stringWithUTF8String: path]; + NSString *p = [NSString stringWithUTF8String: path]; if (![p hasPrefix:@"/dev/"]) { PrefsRemoveItem("cdrom", index); } else {