mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-23 19:31:00 +00:00
added contains() to AppleFileSource
This commit is contained in:
parent
922956086c
commit
1b1726a5e0
@ -8,25 +8,27 @@ import com.bytezone.diskbrowser.gui.DataSource;
|
||||
|
||||
public interface AppleFileSource
|
||||
{
|
||||
/*
|
||||
* Returns a name that uniquely identifies this object within the disk.
|
||||
*/
|
||||
public String getUniqueName ();
|
||||
/*
|
||||
* Returns a name that uniquely identifies this object within the disk.
|
||||
*/
|
||||
public String getUniqueName ();
|
||||
|
||||
/*
|
||||
* DataSource is implemented by AbstractSector and AbstractFile, and provides
|
||||
* routines to display the data in various formats (text, hex, assembler and
|
||||
* image).
|
||||
*/
|
||||
public DataSource getDataSource ();
|
||||
/*
|
||||
* DataSource is implemented by AbstractSector and AbstractFile, and provides
|
||||
* routines to display the data in various formats (text, hex, assembler and
|
||||
* image).
|
||||
*/
|
||||
public DataSource getDataSource ();
|
||||
|
||||
/*
|
||||
* Returns a list of sectors used by this object.
|
||||
*/
|
||||
public List<DiskAddress> getSectors ();
|
||||
/*
|
||||
* Returns a list of sectors used by this object.
|
||||
*/
|
||||
public List<DiskAddress> getSectors ();
|
||||
|
||||
/*
|
||||
* Returns the actual FormattedDisk that owns this object.
|
||||
*/
|
||||
public FormattedDisk getFormattedDisk ();
|
||||
/*
|
||||
* Returns the actual FormattedDisk that owns this object.
|
||||
*/
|
||||
public FormattedDisk getFormattedDisk ();
|
||||
|
||||
public boolean contains (DiskAddress diskAddress);
|
||||
}
|
@ -81,6 +81,15 @@ public class DirectoryEntry implements AppleFileSource
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
for (DiskAddress sector : blocks)
|
||||
if (sector.compareTo (da) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String line ()
|
||||
{
|
||||
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||
|
@ -29,7 +29,6 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
protected ActionListener actionListenerList;
|
||||
protected JTree catalogTree;
|
||||
protected Path originalPath;
|
||||
// protected String originalName;
|
||||
|
||||
protected List<SectorType> sectorTypesList = new ArrayList<SectorType> ();
|
||||
protected List<AppleFileSource> fileEntries = new ArrayList<AppleFileSource> ();
|
||||
@ -40,7 +39,6 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
|
||||
public final SectorType emptySector = new SectorType ("Unused (empty)", Color.white);
|
||||
public final SectorType usedSector = new SectorType ("Unused (data)", Color.yellow);
|
||||
// public final SectorType dosSector = new SectorType ("DOS", Color.lightGray);
|
||||
|
||||
protected int falsePositives;
|
||||
protected int falseNegatives;
|
||||
@ -304,6 +302,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
@Override
|
||||
public String getSectorFilename (DiskAddress da)
|
||||
{
|
||||
for (AppleFileSource entry : fileEntries)
|
||||
if (entry.contains (da))
|
||||
return (entry).getUniqueName ();
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class DefaultAppleFileSource implements AppleFileSource
|
||||
}
|
||||
|
||||
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner,
|
||||
List<DiskAddress> blocks)
|
||||
List<DiskAddress> blocks)
|
||||
{
|
||||
this (title, file, owner);
|
||||
this.blocks = blocks;
|
||||
@ -50,16 +50,19 @@ public class DefaultAppleFileSource implements AppleFileSource
|
||||
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource ()
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormattedDisk getFormattedDisk ()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiskAddress> getSectors ()
|
||||
{
|
||||
return blocks;
|
||||
@ -77,12 +80,22 @@ public class DefaultAppleFileSource implements AppleFileSource
|
||||
|
||||
if (title.length () > MAX_NAME_LENGTH)
|
||||
return title.substring (0, PREFIX_LENGTH) + "..."
|
||||
+ title.substring (title.length () - SUFFIX_LENGTH);
|
||||
+ title.substring (title.length () - SUFFIX_LENGTH);
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName ()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (DiskAddress diskAddress)
|
||||
{
|
||||
for (DiskAddress da : blocks)
|
||||
if (da.compareTo (diskAddress) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -257,7 +257,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
return appleFile;
|
||||
}
|
||||
|
||||
boolean contains (DiskAddress da)
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
for (DiskAddress sector : tsSectors)
|
||||
if (sector.compareTo (da) == 0)
|
||||
|
@ -337,14 +337,14 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
return super.getFormattedSector (da);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSectorFilename (DiskAddress da)
|
||||
{
|
||||
for (AppleFileSource ce : fileEntries)
|
||||
if (((CatalogEntry) ce).contains (da))
|
||||
return ((CatalogEntry) ce).name;
|
||||
return null;
|
||||
}
|
||||
// @Override
|
||||
// public String getSectorFilename (DiskAddress da)
|
||||
// {
|
||||
// for (AppleFileSource ce : fileEntries)
|
||||
// if (((CatalogEntry) ce).contains (da))
|
||||
// return ((CatalogEntry) ce).name;
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DiskAddress> getFileSectors (int fileNo)
|
||||
|
@ -37,7 +37,8 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
blocks.add (disk.getDiskAddress (i));
|
||||
}
|
||||
|
||||
boolean contains (DiskAddress da)
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
for (DiskAddress sector : blocks)
|
||||
if (sector.compareTo (da) == 0)
|
||||
|
@ -48,6 +48,15 @@ class PascalCodeObject implements AppleFileSource
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
for (DiskAddress sector : blocks)
|
||||
if (sector.compareTo (da) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName ()
|
||||
{
|
||||
|
@ -48,4 +48,13 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
{
|
||||
return parentDisk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (DiskAddress da)
|
||||
{
|
||||
for (DiskAddress sector : dataBlocks)
|
||||
if (sector.compareTo (da) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -234,14 +234,14 @@ public class ProdosDisk extends AbstractFormattedDisk
|
||||
return super.getFormattedSector (da);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSectorFilename (DiskAddress da)
|
||||
{
|
||||
for (AppleFileSource fe : fileEntries)
|
||||
if (((FileEntry) fe).contains (da))
|
||||
return ((FileEntry) fe).getUniqueName ();
|
||||
return null;
|
||||
}
|
||||
// @Override
|
||||
// public String getSectorFilename (DiskAddress da)
|
||||
// {
|
||||
// for (AppleFileSource fe : fileEntries)
|
||||
// if (((FileEntry) fe).contains (da))
|
||||
// return ((FileEntry) fe).getUniqueName ();
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<DiskAddress> getFileSectors (int fileNo)
|
||||
|
Loading…
Reference in New Issue
Block a user