diff --git a/src/main/java/com/webcodepro/applecommander/storage/DiskCorruptException.java b/src/main/java/com/webcodepro/applecommander/storage/DiskCorruptException.java
index 2ead92b..6e04bc0 100644
--- a/src/main/java/com/webcodepro/applecommander/storage/DiskCorruptException.java
+++ b/src/main/java/com/webcodepro/applecommander/storage/DiskCorruptException.java
@@ -30,10 +30,29 @@ public class DiskCorruptException extends DiskException {
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
+ public enum Kind {
+ RECURSIVE_DIRECTORY_STRUCTURE
+ }
+
+ final public Kind kind;
+ final public Object offender;
+
+ private DiskCorruptException(String description) {
+ super(description);
+ this.kind = null;
+ this.offender = null;
+ }
+
/**
* Constructor for DiskFullException.
*/
- public DiskCorruptException(String description) {
+ public DiskCorruptException(String description, Kind kind, Object offender) {
super(description);
+ this.kind = kind;
+ this.offender = offender;
+ }
+
+ public String toString() {
+ return super.toString() + " @ " + offender.toString();
}
}
diff --git a/src/main/java/com/webcodepro/applecommander/storage/DiskException.java b/src/main/java/com/webcodepro/applecommander/storage/DiskException.java
index 2114316..1cb4ef3 100644
--- a/src/main/java/com/webcodepro/applecommander/storage/DiskException.java
+++ b/src/main/java/com/webcodepro/applecommander/storage/DiskException.java
@@ -20,18 +20,17 @@
package com.webcodepro.applecommander.storage;
/**
- * A DiskFullException is thrown during a write operation when the file
- * being written will not fit on the disk.
+ * A DiskException is the base class for Disk Exceptions.
*
- * Created on Dec 23, 2002.
- * @author Rob Greene
+ * Created on Nov 30, 2017.
+ * @author Lisias Toledo
*/
-public class DiskException extends Exception {
+public abstract class DiskException extends Exception {
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
/**
- * Constructor for DiskFullException.
+ * Constructor for DiskException.
*/
public DiskException(String description) {
super(description);
diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java
index d3bfc35..68adce7 100644
--- a/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java
+++ b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java
@@ -152,7 +152,7 @@ public class DosFormatDisk extends FormattedDisk {
// Prevents a recursive catalog crawling.
if ( !visits.containsKey(track) ) visits.put(track, new HashMap());
- if ( visits.get(track).containsKey(sector)) throw new DiskCorruptException("Recursive Directory structure detected.");
+ if ( visits.get(track).containsKey(sector)) throw new DiskCorruptException("Recursive Directory structure detected.", DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new DosSectorAddress(track, sector));
else visits.get(track).put(sector, Boolean.TRUE);
byte[] catalogSector = readSector(track, sector);
diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosSectorAddress.java b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosSectorAddress.java
new file mode 100644
index 0000000..96ecbfe
--- /dev/null
+++ b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosSectorAddress.java
@@ -0,0 +1,41 @@
+/*
+ * AppleCommander - An Apple ][ image utility.
+ * Copyright (C) 2002 by Robert Greene
+ * robgreene at users.sourceforge.net
+ *
+ * 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 the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.webcodepro.applecommander.storage.os.dos33;
+
+/**
+ * A Container for DOS 3.3 Sector Addresses.
+ *
+ * Created on Dec 13, 2017.
+ * @author Lisias Toledo
+ */
+public class DosSectorAddress {
+
+ public final Integer track;
+ public final Integer sector;
+
+ public DosSectorAddress(int track, int sector) {
+ this.track = track;
+ this.sector = sector;
+ }
+
+ public String toString() {
+ return "Track:" + this.track + ", Sector:" + this.sector;
+ }
+}
diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosBlockAddress.java b/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosBlockAddress.java
new file mode 100644
index 0000000..2f8d3f1
--- /dev/null
+++ b/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosBlockAddress.java
@@ -0,0 +1,39 @@
+/*
+ * AppleCommander - An Apple ][ image utility.
+ * Copyright (C) 2002 by Robert Greene
+ * robgreene at users.sourceforge.net
+ *
+ * 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 the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.webcodepro.applecommander.storage.os.prodos;
+
+/**
+ * A Container for DOS 3.3 Sector Addresses.
+ *
+ * Created on Dec 13, 2017.
+ * @author Lisias Toledo
+ */
+public class ProdosBlockAddress {
+
+ public final Integer number;
+
+ public ProdosBlockAddress(int number) {
+ this.number = number;
+ }
+
+ public String toString() {
+ return "Block:" + this.number;
+ }
+}
diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java b/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java
index 27fa001..7ba45e5 100644
--- a/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java
+++ b/src/main/java/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java
@@ -278,7 +278,7 @@ public class ProdosFormatDisk extends FormattedDisk {
final Map visits = new HashMap<>();
while (blockNumber != 0) {
// Prevents a recursive catalog crawling.
- if ( visits.containsKey(blockNumber)) throw new DiskCorruptException("Recursive Directory structure detected.");
+ if ( visits.containsKey(blockNumber)) throw new DiskCorruptException("Recursive Directory structure detected.", DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new ProdosBlockAddress(blockNumber));
else visits.put(blockNumber, Boolean.TRUE);
byte[] block = readBlock(blockNumber);