Handles file size of 0 appropriately.

This commit is contained in:
Robert Greene 2003-12-22 23:01:22 +00:00
parent a739924dd6
commit 4dc90d5165
2 changed files with 10 additions and 1 deletions

View File

@ -183,6 +183,7 @@ public class DosFileEntry implements FileEntry {
}
// default to nothing special, just compute from number of sectors
int size = (getSectorsUsed()-1) * Disk.SECTOR_SIZE;
if (size < 1) size = 0; // we assume a T/S block is included (may not be)
if (rawdata != null) {
if ("B".equals(getFiletype())) {
// binary

View File

@ -398,7 +398,15 @@ public class DosFormatDisk extends FormattedDisk {
DosFileEntry dosEntry = (DosFileEntry) fileEntry;
// Size is calculated by sectors used - not actual size - as size varies
// on filetype, etc.
byte[] fileData = new byte[(dosEntry.getSectorsUsed()-1) * SECTOR_SIZE];
int filesize = dosEntry.getSectorsUsed();
byte[] fileData = null;
if (filesize > 0) {
fileData = new byte[(dosEntry.getSectorsUsed()-1) * SECTOR_SIZE];
} else {
fileData = new byte[0];
// don't need to load it - also bypass potential issues
return fileData;
}
int track = dosEntry.getTrack();
int sector = dosEntry.getSector();
int offset = 0;