better empty file handling

This commit is contained in:
Denis Molony 2020-10-28 18:26:29 +10:00
parent 1b57001315
commit 080cafcd22
3 changed files with 9 additions and 6 deletions

View File

@ -60,8 +60,7 @@ abstract class CatalogEntry implements AppleFileSource
public List<DiskAddress> getSectors () public List<DiskAddress> getSectors ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
List<DiskAddress> sectors = new ArrayList<> (blocks); return new ArrayList<> (blocks); // make a copy
return sectors;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -61,16 +61,19 @@ public class FileEntry extends CatalogEntry
public AbstractFile getDataSource () public AbstractFile getDataSource ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (file != null) if (file != null) // previously built
return file; return file;
byte[] buffer = getExactBuffer (); // check for empty file (e.g. see DC16.dsk)
if (buffer.length == 0) if (firstBlock == lastBlock)
{ {
file = new AssemblerProgram (name, buffer, 0); // see DC16.dsk file = new DefaultAppleFile (name, new byte[0]);
node.setAllowsChildren (false);
return file; return file;
} }
byte[] buffer = getExactBuffer ();
switch (fileType) switch (fileType)
{ {
case 2: // code (6502 or Pascal) case 2: // code (6502 or Pascal)

View File

@ -22,6 +22,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
import com.bytezone.diskbrowser.utilities.Utility; import com.bytezone.diskbrowser.utilities.Utility;
import com.bytezone.diskbrowser.wizardry.Relocator; import com.bytezone.diskbrowser.wizardry.Relocator;
// useful : http://pascal.hansotten.com/ucsd-p-system/apple-pascal/apple-ii/
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
public class PascalDisk extends AbstractFormattedDisk public class PascalDisk extends AbstractFormattedDisk
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//