mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-04-20 18:17:12 +00:00
Adding DiskDiff and enhancing the basic disk comparison capabilities.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* AppleCommander - An Apple ][ image utility.
|
||||
* Copyright (C) 2021-2022 by Robert Greene and others
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Indicates the broad disk geometry - track/sector or block.
|
||||
* Note that BLOCK is meant to include only ProDOS/Pascal 512-byte
|
||||
* blocks and not the RDOS 256 "blocks" (RDOS should remain under
|
||||
* the track/sector geometry.)
|
||||
*/
|
||||
public enum DiskGeometry {
|
||||
TRACK_SECTOR(256, "Track/Sector"),
|
||||
BLOCK(512, "Block");
|
||||
|
||||
public int size;
|
||||
public String text;
|
||||
|
||||
private DiskGeometry(int size, String text) {
|
||||
this.size = size;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -399,4 +399,9 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
|
||||
* Typically, the FileEntry.setFileData method should be used.
|
||||
*/
|
||||
public abstract void setFileData(FileEntry fileEntry, byte[] fileData) throws DiskFullException;
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public abstract DiskGeometry getDiskGeometry();
|
||||
}
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* AppleCommander - An Apple ][ image utility.
|
||||
* Copyright (C) 2021-2022 by Robert Greene and others
|
||||
* 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.compare;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ComparisonResult {
|
||||
private List<String> errors = new ArrayList<>();
|
||||
private List<String> warnings = new ArrayList<>();
|
||||
|
||||
public boolean hasErrors() {
|
||||
return !errors.isEmpty();
|
||||
}
|
||||
public int getDifferenceCount() {
|
||||
return errors.size() + warnings.size();
|
||||
}
|
||||
|
||||
public void addError(Exception ex) {
|
||||
errors.add(ex.getMessage());
|
||||
}
|
||||
public void addError(String fmt, Object... args) {
|
||||
errors.add(String.format(fmt, args));
|
||||
}
|
||||
public void addWarning(String fmt, Object... args) {
|
||||
warnings.add(String.format(fmt, args));
|
||||
}
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
public List<String> getWarnings() {
|
||||
return warnings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* AppleCommander - An Apple ][ image utility.
|
||||
* Copyright (C) 2021-2022 by Robert Greene and others
|
||||
* 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.compare;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.webcodepro.applecommander.storage.Disk;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.DiskUnrecognizedException;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.physical.ImageOrder;
|
||||
|
||||
/**
|
||||
* Perform a disk comparison based on selected strategy.
|
||||
*/
|
||||
public class DiskDiff {
|
||||
public static ComparisonResult compare(Disk diskA, Disk diskB) {
|
||||
return new DiskDiff(diskA, diskB).compare();
|
||||
}
|
||||
public static Builder create(Disk diskA, Disk diskB) {
|
||||
return new Builder(diskA, diskB);
|
||||
}
|
||||
|
||||
private Disk diskA;
|
||||
private Disk diskB;
|
||||
private ComparisonResult results = new ComparisonResult();
|
||||
|
||||
private BiConsumer<FormattedDisk,FormattedDisk> diskComparisonStrategy = this::compareByNativeGeometry;
|
||||
|
||||
private DiskDiff(Disk diskA, Disk diskB) {
|
||||
Objects.requireNonNull(diskA);
|
||||
Objects.requireNonNull(diskB);
|
||||
this.diskA = diskA;
|
||||
this.diskB = diskB;
|
||||
}
|
||||
|
||||
public ComparisonResult compare() {
|
||||
FormattedDisk[] formattedDisksA = null;
|
||||
try {
|
||||
formattedDisksA = diskA.getFormattedDisks();
|
||||
} catch (DiskUnrecognizedException e) {
|
||||
results.addError(e);
|
||||
}
|
||||
FormattedDisk[] formattedDisksB = null;
|
||||
try {
|
||||
formattedDisksB = diskB.getFormattedDisks();
|
||||
} catch (DiskUnrecognizedException e) {
|
||||
results.addError(e);
|
||||
}
|
||||
|
||||
if (!results.hasErrors()) {
|
||||
compareAll(formattedDisksA, formattedDisksB);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void compareAll(FormattedDisk[] formattedDisksA, FormattedDisk[] formattedDisksB) {
|
||||
Objects.requireNonNull(formattedDisksA);
|
||||
Objects.requireNonNull(formattedDisksB);
|
||||
|
||||
if (formattedDisksA.length != formattedDisksB.length) {
|
||||
results.addWarning("Cannot compare all disks; %s has %d while %s has %d.",
|
||||
diskA.getFilename(), formattedDisksA.length,
|
||||
diskB.getFilename(), formattedDisksB.length);
|
||||
}
|
||||
|
||||
int min = Math.min(formattedDisksA.length, formattedDisksB.length);
|
||||
for (int i=0; i<min; i++) {
|
||||
this.diskComparisonStrategy.accept(formattedDisksA[i], formattedDisksB[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Compare disks by whatever native geometry the disks have. Fails if geometries do not match. */
|
||||
public void compareByNativeGeometry(FormattedDisk formattedDiskA, FormattedDisk formattedDiskB) {
|
||||
DiskGeometry geometryA = formattedDiskA.getDiskGeometry();
|
||||
DiskGeometry geometryB = formattedDiskB.getDiskGeometry();
|
||||
|
||||
if (geometryA != geometryB) {
|
||||
results.addError("Disks are different geometry (block versus track/sector)");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (geometryA) {
|
||||
case BLOCK:
|
||||
compareByBlockGeometry(formattedDiskA, formattedDiskB);
|
||||
break;
|
||||
case TRACK_SECTOR:
|
||||
compareByTrackSectorGeometry(formattedDiskA, formattedDiskB);
|
||||
break;
|
||||
default:
|
||||
results.addError("Unknown geometry: %s", geometryA);
|
||||
}
|
||||
}
|
||||
|
||||
/** Compare disks by 512-byte ProDOS/Pascal blocks. */
|
||||
public void compareByBlockGeometry(FormattedDisk formattedDiskA, FormattedDisk formattedDiskB) {
|
||||
ImageOrder orderA = formattedDiskA.getImageOrder();
|
||||
ImageOrder orderB = formattedDiskB.getImageOrder();
|
||||
|
||||
if (orderA.getBlocksOnDevice() != orderB.getBlocksOnDevice()) {
|
||||
results.addError("Different sized disks do not equal. (Blocks: %d <> %d)",
|
||||
orderA.getBlocksOnDevice(), orderB.getBlocksOnDevice());
|
||||
return;
|
||||
}
|
||||
|
||||
for (int block=0; block<orderA.getBlocksOnDevice(); block++) {
|
||||
byte[] blockA = orderA.readBlock(block);
|
||||
byte[] blockB = orderB.readBlock(block);
|
||||
if (!Arrays.equals(blockA, blockB)) {
|
||||
results.addError("Block #%d does not match.", block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Compare disks by 256-byte DOS sectors. */
|
||||
public void compareByTrackSectorGeometry(FormattedDisk formattedDiskA, FormattedDisk formattedDiskB) {
|
||||
ImageOrder orderA = formattedDiskA.getImageOrder();
|
||||
ImageOrder orderB = formattedDiskB.getImageOrder();
|
||||
|
||||
if (orderA.getSectorsPerDisk() != orderB.getSectorsPerDisk()) {
|
||||
results.addError("Different sized disks do not equal. (Sectors: %d <> %d)",
|
||||
orderA.getSectorsPerDisk(), orderB.getSectorsPerDisk());
|
||||
return;
|
||||
}
|
||||
|
||||
for (int track=0; track<orderA.getTracksPerDisk(); track++) {
|
||||
List<String> unequalSectors = new ArrayList<>();
|
||||
for (int sector=0; sector<orderA.getSectorsPerTrack(); sector++) {
|
||||
byte[] sectorA = orderA.readSector(track, sector);
|
||||
byte[] sectorB = orderB.readSector(track, sector);
|
||||
if (!Arrays.equals(sectorA, sectorB)) {
|
||||
unequalSectors.add(Integer.toString(sector));
|
||||
}
|
||||
}
|
||||
if (!unequalSectors.isEmpty()) {
|
||||
results.addError("Track %d does not match on sectors %s", track,
|
||||
String.join(",", unequalSectors));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private DiskDiff diff;
|
||||
|
||||
public Builder(Disk diskA, Disk diskB) {
|
||||
diff = new DiskDiff(diskA, diskB);
|
||||
}
|
||||
/** Compare disks by whatever native geometry the disks have. Fails if geometries do not match. */
|
||||
public Builder selectCompareByNativeGeometry() {
|
||||
diff.diskComparisonStrategy = diff::compareByNativeGeometry;
|
||||
return this;
|
||||
}
|
||||
/** Compare disks by 256-byte DOS sectors. */
|
||||
public Builder selectCompareByTrackSectorGeometry() {
|
||||
diff.diskComparisonStrategy = diff::compareByTrackSectorGeometry;
|
||||
return this;
|
||||
}
|
||||
/** Compare disks by 512-byte ProDOS/Pascal blocks. */
|
||||
public Builder selectCompareByBlockGeometry() {
|
||||
diff.diskComparisonStrategy = diff::compareByBlockGeometry;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ComparisonResult compare() {
|
||||
return diff.compare();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -27,6 +27,7 @@ import java.util.StringTokenizer;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -557,4 +558,11 @@ public class CpmFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.TRACK_SECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -28,6 +28,7 @@ import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskException;
|
||||
import com.webcodepro.applecommander.storage.DiskCorruptException;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -773,4 +774,11 @@ public class DosFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.TRACK_SECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -699,4 +700,11 @@ public class GutenbergFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.TRACK_SECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -537,4 +538,11 @@ public class NakedosFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.TRACK_SECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -667,4 +668,11 @@ public class PascalFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -32,6 +32,7 @@ import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskException;
|
||||
import com.webcodepro.applecommander.storage.DiskCorruptException;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -1450,4 +1451,11 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||
throw new DiskFullException(textBundle.get("ProdosFormatDisk.UnableToAllocateFileEntry"), this.getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.DiskGeometry;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||
@@ -518,4 +519,11 @@ public class RdosFormatDisk extends FormattedDisk {
|
||||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
throw new UnsupportedOperationException(textBundle.get("DirectoryCreationNotSupported")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives an indication on how this disk's geometry should be handled.
|
||||
*/
|
||||
public DiskGeometry getDiskGeometry() {
|
||||
return DiskGeometry.TRACK_SECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,10 @@ package com.webcodepro.applecommander.util;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||
import com.webcodepro.applecommander.storage.physical.ImageOrder;
|
||||
|
||||
/**
|
||||
@@ -615,28 +613,6 @@ public class AppleUtil {
|
||||
protected static boolean sameSectorsPerDisk(ImageOrder sourceOrder, ImageOrder targetOrder) {
|
||||
return sourceOrder.getSectorsPerDisk() == targetOrder.getSectorsPerDisk();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two disks by track and sector.
|
||||
*/
|
||||
public static boolean disksEqualByTrackAndSector(FormattedDisk sourceDisk, FormattedDisk targetDisk) {
|
||||
ImageOrder sourceOrder = sourceDisk.getImageOrder();
|
||||
ImageOrder targetOrder = targetDisk.getImageOrder();
|
||||
if (!sameSectorsPerDisk(sourceOrder, targetOrder)) {
|
||||
throw new IllegalArgumentException(textBundle.
|
||||
get("AppleUtil.CannotCompareDisks")); //$NON-NLS-1$
|
||||
}
|
||||
for (int track = 0; track < sourceOrder.getTracksPerDisk(); track++) {
|
||||
for (int sector = 0; sector < sourceOrder.getSectorsPerTrack(); sector++) {
|
||||
byte[] sourceData = sourceOrder.readSector(track, sector);
|
||||
byte[] targetData = targetOrder.readSector(track, sector);
|
||||
if (!Arrays.equals(sourceData, targetData)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change ImageOrder from source order to target order by copying block by block.
|
||||
@@ -658,24 +634,4 @@ public class AppleUtil {
|
||||
protected static boolean sameBlocksPerDisk(ImageOrder sourceOrder, ImageOrder targetOrder) {
|
||||
return sourceOrder.getBlocksOnDevice() == targetOrder.getBlocksOnDevice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two disks block by block.
|
||||
*/
|
||||
public static boolean disksEqualByBlock(FormattedDisk sourceDisk, FormattedDisk targetDisk) {
|
||||
ImageOrder sourceOrder = sourceDisk.getImageOrder();
|
||||
ImageOrder targetOrder = targetDisk.getImageOrder();
|
||||
if (!sameBlocksPerDisk(sourceOrder, targetOrder)) {
|
||||
throw new IllegalArgumentException(textBundle.
|
||||
get("AppleUtil.CannotCompareDisks")); //$NON-NLS-1$
|
||||
}
|
||||
for (int block = 0; block < sourceOrder.getBlocksOnDevice(); block++) {
|
||||
byte[] sourceData = sourceOrder.readBlock(block);
|
||||
byte[] targetData = targetOrder.readBlock(block);
|
||||
if (!Arrays.equals(sourceData, targetData)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,10 +289,10 @@ CompareDisksStartPane.DiskNLabel=Please select disk image \#{0}:
|
||||
|
||||
# CompareDisksResultsPane
|
||||
CompareDisksResultsPane.RestartText=If you wish to compare more disks, click back and start again.
|
||||
CompareDisksResultsPane.UnableToLoadDiskN=Unable to load disk \#{0}: {1}\n
|
||||
CompareDisksResultsPane.DifferentSizeError=The two disks are of differing formats - unable to compare.\n
|
||||
CompareDisksResultsPane.DataDiffersMessage=The two disks do not contain the same data.\n
|
||||
CompareDisksResultsPane.DifferentDataFormatError=The two disks are not the same data format.\n
|
||||
CompareDisksResultsPane.UnableToLoadDiskN=Unable to load disk \#{0}: {1}
|
||||
CompareDisksResultsPane.DifferentSizeError=The two disks are of differing formats - unable to compare.
|
||||
CompareDisksResultsPane.DataDiffersMessage=The two disks do not contain the same data.
|
||||
CompareDisksResultsPane.DifferentDataFormatError=The two disks are not the same data format.
|
||||
CompareDisksResultsPane.DisksMatch=The disk images match.
|
||||
|
||||
# GraphicsFilterAdapter
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.junit.Test;
|
||||
import com.webcodepro.applecommander.storage.Disk;
|
||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||
import com.webcodepro.applecommander.storage.FileEntry;
|
||||
import com.webcodepro.applecommander.storage.compare.ComparisonResult;
|
||||
import com.webcodepro.applecommander.storage.compare.DiskDiff;
|
||||
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
|
||||
import com.webcodepro.applecommander.storage.os.prodos.ProdosFormatDisk;
|
||||
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout;
|
||||
@@ -92,7 +94,9 @@ public class AppleUtilTest {
|
||||
AppleUtil.changeImageOrderByTrackAndSector(dosDiskDosOrder.getImageOrder(),
|
||||
dosDiskNibbleOrder.getImageOrder());
|
||||
// Confirm that these disks are identical:
|
||||
assertTrue(AppleUtil.disksEqualByTrackAndSector(dosDiskDosOrder, dosDiskNibbleOrder));
|
||||
ComparisonResult result = DiskDiff.create(dosDiskDosOrder, dosDiskDosOrder)
|
||||
.selectCompareByTrackSectorGeometry().compare();
|
||||
assertEquals("Expected disks to have no differences", 0, result.getDifferenceCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,7 +116,9 @@ public class AppleUtilTest {
|
||||
AppleUtil.changeImageOrderByBlock(prodosDiskDosOrder.getImageOrder(),
|
||||
prodosDiskNibbleOrder.getImageOrder());
|
||||
// Confirm that these disks are identical:
|
||||
assertTrue(AppleUtil.disksEqualByBlock(prodosDiskDosOrder, prodosDiskNibbleOrder));
|
||||
ComparisonResult result = DiskDiff.create(prodosDiskDosOrder, prodosDiskNibbleOrder)
|
||||
.selectCompareByBlockGeometry().compare();
|
||||
assertEquals("Expected disks to have no differences", 0, result.getDifferenceCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user