mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 23:29:34 +00:00
Added resizeDiskImage capability.
This commit is contained in:
parent
b3716c3195
commit
bda3c40749
@ -266,6 +266,23 @@ public class Disk {
|
||||
return diskImage.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize a disk image up to a larger size. The primary intention is to
|
||||
* "fix" disk images that have been created too small. The primary culprit
|
||||
* is ApplePC HDV images which dynamically grow. Since AppleCommander
|
||||
* works with a byte array, the image must grow to its full size.
|
||||
* @param newSize
|
||||
*/
|
||||
protected void resizeDiskImage(int newSize) {
|
||||
if (newSize < diskImage.length) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot resize a disk to be smaller than the current size!");
|
||||
}
|
||||
byte[] newDiskImage = new byte[newSize];
|
||||
System.arraycopy(diskImage, 0, newDiskImage, 0, diskImage.length);
|
||||
diskImage = newDiskImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the block from the disk image.
|
||||
*/
|
||||
|
@ -354,4 +354,12 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
|
||||
public FormattedDisk getFormattedDisk() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the disk image to be its full size. Only invole this
|
||||
* method if a size does not match exception is thrown.
|
||||
*/
|
||||
public void resizeDiskImage() {
|
||||
resizeDiskImage(getFreeSpace() + getUsedSpace());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user