Detailing the exception for further analysis and rescuing efforts as suggested in:
https://github.com/AppleCommander/AppleCommander/pull/19#discussion_r156263263
This commit is contained in:
parent
50608b9c43
commit
7b729b9d0b
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <br>
|
||||
* 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);
|
||||
|
|
|
@ -152,7 +152,7 @@ public class DosFormatDisk extends FormattedDisk {
|
|||
|
||||
// Prevents a recursive catalog crawling.
|
||||
if ( !visits.containsKey(track) ) visits.put(track, new HashMap<Integer,Boolean>());
|
||||
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);
|
||||
|
|
|
@ -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.
|
||||
* <br>
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
* <br>
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -278,7 +278,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
|||
final Map<Integer,Boolean> 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);
|
||||
|
|
Loading…
Reference in New Issue