Somewhat better DiskCorruptException handling. Avoiding redundancy.
This commit is contained in:
parent
f3316262c8
commit
144841a296
|
@ -31,13 +31,17 @@ public class DiskCorruptException extends DiskException {
|
||||||
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
||||||
|
|
||||||
public enum Kind {
|
public enum Kind {
|
||||||
RECURSIVE_DIRECTORY_STRUCTURE
|
RECURSIVE_DIRECTORY_STRUCTURE {
|
||||||
|
public String toString() {
|
||||||
|
return "Recursive Directory structure detected."; // FIXME NLS
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public Kind kind;
|
final public Kind kind;
|
||||||
final public Object offender;
|
final public Object offender;
|
||||||
|
|
||||||
private DiskCorruptException(String description) {
|
private DiskCorruptException(final String description) {
|
||||||
super(description);
|
super(description);
|
||||||
this.kind = null;
|
this.kind = null;
|
||||||
this.offender = null;
|
this.offender = null;
|
||||||
|
@ -46,8 +50,8 @@ public class DiskCorruptException extends DiskException {
|
||||||
/**
|
/**
|
||||||
* Constructor for DiskFullException.
|
* Constructor for DiskFullException.
|
||||||
*/
|
*/
|
||||||
public DiskCorruptException(String description, Kind kind, Object offender) {
|
public DiskCorruptException(final Kind kind, final Object offender) {
|
||||||
super(description);
|
super(kind.toString());
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.offender = offender;
|
this.offender = offender;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class DosFormatDisk extends FormattedDisk {
|
||||||
|
|
||||||
// Prevents a recursive catalog crawling.
|
// Prevents a recursive catalog crawling.
|
||||||
final DosSectorAddress address = new DosSectorAddress(track, sector);
|
final DosSectorAddress address = new DosSectorAddress(track, sector);
|
||||||
if ( visits.contains(address)) throw new DiskCorruptException("Recursive Directory structure detected.", DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, address);
|
if ( visits.contains(address)) throw new DiskCorruptException(DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, address);
|
||||||
else visits.add(address);
|
else visits.add(address);
|
||||||
|
|
||||||
byte[] catalogSector = readSector(track, sector);
|
byte[] catalogSector = readSector(track, sector);
|
||||||
|
|
|
@ -278,7 +278,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
final Set<Integer> visits = new HashSet<>();
|
final Set<Integer> visits = new HashSet<>();
|
||||||
while (blockNumber != 0) {
|
while (blockNumber != 0) {
|
||||||
// Prevents a recursive catalog crawling.
|
// Prevents a recursive catalog crawling.
|
||||||
if ( visits.contains(blockNumber)) throw new DiskCorruptException("Recursive Directory structure detected.", DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new ProdosBlockAddress(blockNumber));
|
if ( visits.contains(blockNumber)) throw new DiskCorruptException(DiskCorruptException.Kind.RECURSIVE_DIRECTORY_STRUCTURE, new ProdosBlockAddress(blockNumber));
|
||||||
else visits.add(blockNumber);
|
else visits.add(blockNumber);
|
||||||
|
|
||||||
byte[] block = readBlock(blockNumber);
|
byte[] block = readBlock(blockNumber);
|
||||||
|
|
Loading…
Reference in New Issue