mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-09-28 15:55:34 +00:00
Compare commits
No commits in common. "6f943ae8c2f17342708270bc0bdc75084631c7a8" and "37c489f252402f14d95a5f6d7fe6e51c6ed03a27" have entirely different histories.
6f943ae8c2
...
37c489f252
@ -88,7 +88,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
if (b1 > 31 && b1 != EMPTY_BYTE_VALUE)
|
if (b1 > 31 && b1 != EMPTY_BYTE_VALUE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (int i = 0; i < buffer.length; i += 32)
|
for (int i = 0; i < buffer.length; i += 32)
|
||||||
@ -99,7 +99,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
if (b1 == EMPTY_BYTE_VALUE) // deleted file??
|
if (b1 == EMPTY_BYTE_VALUE) // deleted file??
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (b2 <= 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
if (b2 < 32 || (b2 > 126 && b2 != EMPTY_BYTE_VALUE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
DirectoryEntry entry = new DirectoryEntry (this, buffer, i);
|
||||||
@ -188,8 +188,9 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String line = "---- --------- --- - - -- -- -- -- ----------------------------"
|
String line =
|
||||||
+ "-------------------\n";
|
"---- --------- --- - - -- -- -- -- ----------------------------"
|
||||||
|
+ "-------------------\n";
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("File : %s%n%n", getDisplayPath ()));
|
text.append (String.format ("File : %s%n%n", getDisplayPath ()));
|
||||||
text.append ("User Name Typ R S Ex S2 S1 RC Blocks\n");
|
text.append ("User Name Typ R S Ex S2 S1 RC Blocks\n");
|
||||||
|
@ -139,8 +139,9 @@ class DirectoryEntry implements AppleFileSource
|
|||||||
char ro = readOnly ? '*' : ' ';
|
char ro = readOnly ? '*' : ' ';
|
||||||
char sf = systemFile ? '*' : ' ';
|
char sf = systemFile ? '*' : ' ';
|
||||||
|
|
||||||
String text = String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
String text =
|
||||||
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
|
||||||
|
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
|
||||||
for (DirectoryEntry entry : entries)
|
for (DirectoryEntry entry : entries)
|
||||||
text = text + "\n" + entry.line ();
|
text = text + "\n" + entry.line ();
|
||||||
|
|
||||||
@ -217,13 +218,14 @@ class DirectoryEntry implements AppleFileSource
|
|||||||
else if ("DVR".equals (type))
|
else if ("DVR".equals (type))
|
||||||
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
|
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
|
||||||
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|
||||||
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type) || "ALX".equals (type)
|
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type)
|
||||||
|| "SRC".equals (type) || "H".equals (type) || exactBuffer[len - 1] == 0x1A)
|
|| "ALX".equals (type) || "SRC".equals (type) || "H".equals (type)
|
||||||
|
|| exactBuffer[len - 1] == 0x1A)
|
||||||
appleFile = new CPMTextFile (name, exactBuffer);
|
appleFile = new CPMTextFile (name, exactBuffer);
|
||||||
else if ("BAS".equals (type))
|
else if ("BAS".equals (type))
|
||||||
appleFile = new CPMBasicFile (name, exactBuffer);
|
appleFile = new CPMBasicFile (name, exactBuffer);
|
||||||
else
|
else
|
||||||
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + name + "." + type);
|
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + type);
|
||||||
|
|
||||||
return appleFile;
|
return appleFile;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class DiskFactory
|
|||||||
|
|
||||||
if ("sdk".equals (suffix) // NuFX disk
|
if ("sdk".equals (suffix) // NuFX disk
|
||||||
|| "shk".equals (suffix) // NuFX files or disk
|
|| "shk".equals (suffix) // NuFX files or disk
|
||||||
|| "bxy".equals (suffix)) // NuFX in Bin2
|
|| "bxy".equals (suffix)) // NuFX in Binary2
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println (" ** sdk/shk/bxy **");
|
System.out.println (" ** sdk/shk/bxy **");
|
||||||
@ -156,11 +156,7 @@ public class DiskFactory
|
|||||||
{
|
{
|
||||||
nuFX = new NuFX (file.toPath ());
|
nuFX = new NuFX (file.toPath ());
|
||||||
if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0)
|
if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0)
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
System.out.println ("Empty NuFX file");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
byte[] diskBuffer = nuFX.getDiskBuffer ();
|
byte[] diskBuffer = nuFX.getDiskBuffer ();
|
||||||
if (diskBuffer == null)
|
if (diskBuffer == null)
|
||||||
@ -187,10 +183,10 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ("bny".equals (suffix) || "bqy".equals (suffix)) // Binary2 uncompressed files
|
else if ("bny".equals (suffix)) // Binary2 uncompressed files
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println (" ** bny/bqy **");
|
System.out.println (" ** bny **");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
binary2 = new Binary2 (file.toPath ());
|
binary2 = new Binary2 (file.toPath ());
|
||||||
|
@ -15,21 +15,27 @@ import com.bytezone.diskbrowser.utilities.DefaultAction;
|
|||||||
public abstract class AbstractSaveAction extends DefaultAction
|
public abstract class AbstractSaveAction extends DefaultAction
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected JFileChooser fileChooser = new JFileChooser ();
|
private JFileChooser fileChooser;
|
||||||
|
private String dialogTitle;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public AbstractSaveAction (String menuText, String tip, String dialogTitle)
|
public AbstractSaveAction (String menuText, String tip, String dialogTitle)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (menuText, tip);
|
super (menuText, tip);
|
||||||
|
this.dialogTitle = dialogTitle;
|
||||||
fileChooser.setDialogTitle (dialogTitle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
void setSelectedFile (File file)
|
void setSelectedFile (File file)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
if (fileChooser == null)
|
||||||
|
{
|
||||||
|
fileChooser = new JFileChooser ();
|
||||||
|
fileChooser.setDialogTitle (dialogTitle);
|
||||||
|
}
|
||||||
|
|
||||||
fileChooser.setSelectedFile (file);
|
fileChooser.setSelectedFile (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,22 +43,26 @@ public abstract class AbstractSaveAction extends DefaultAction
|
|||||||
void saveBuffer (byte[] buffer)
|
void saveBuffer (byte[] buffer)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
|
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
||||||
|
return;
|
||||||
|
|
||||||
File file = fileChooser.getSelectedFile ();
|
File file = fileChooser.getSelectedFile ();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files.write (file.toPath (), buffer, StandardOpenOption.CREATE_NEW);
|
Files.write (file.toPath (), buffer, StandardOpenOption.CREATE_NEW);
|
||||||
JOptionPane.showMessageDialog (null, String.format ("File %s saved", file.getName ()));
|
JOptionPane.showMessageDialog (null,
|
||||||
|
String.format ("File %s saved", file.getName ()));
|
||||||
}
|
}
|
||||||
catch (FileAlreadyExistsException e)
|
catch (FileAlreadyExistsException e)
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists", "Failed",
|
JOptionPane.showMessageDialog (null, "File " + file.getName () + " already exists",
|
||||||
JOptionPane.ERROR_MESSAGE);
|
"Failed", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace ();
|
e.printStackTrace ();
|
||||||
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (), "Failed",
|
JOptionPane.showMessageDialog (null, "File failed to save - " + e.getMessage (),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
"Failed", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ public class FontAction extends DefaultAction implements QuitListener
|
|||||||
{
|
{
|
||||||
super ("Set Font...", "Set display to a different font or font size",
|
super ("Set Font...", "Set display to a different font or font size",
|
||||||
"/com/bytezone/loadlister/");
|
"/com/bytezone/loadlister/");
|
||||||
|
|
||||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F, mask));
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F, mask));
|
||||||
}
|
}
|
||||||
@ -147,7 +146,8 @@ public class FontAction extends DefaultAction implements QuitListener
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
FontChangeEvent fontChangeEvent = new FontChangeEvent (font);
|
FontChangeEvent fontChangeEvent = new FontChangeEvent (font);
|
||||||
FontChangeListener[] listeners = (listenerList.getListeners (FontChangeListener.class));
|
FontChangeListener[] listeners =
|
||||||
|
(listenerList.getListeners (FontChangeListener.class));
|
||||||
for (FontChangeListener listener : listeners)
|
for (FontChangeListener listener : listeners)
|
||||||
listener.changeFont (fontChangeEvent);
|
listener.changeFont (fontChangeEvent);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.bytezone.diskbrowser.gui;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.AppleDisk;
|
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||||
@ -41,9 +40,7 @@ class SaveDiskAction extends AbstractSaveAction implements DiskSelectionListener
|
|||||||
String suffix = blocks <= 560 ? ".dsk" : ".hdv";
|
String suffix = blocks <= 560 ? ".dsk" : ".hdv";
|
||||||
|
|
||||||
setSelectedFile (new File (formattedDisk.getName () + suffix));
|
setSelectedFile (new File (formattedDisk.getName () + suffix));
|
||||||
|
saveBuffer (appleDisk.getBuffer ());
|
||||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
|
||||||
saveBuffer (appleDisk.getBuffer ());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
System.out.println ("Not an AppleDisk"); // impossible
|
System.out.println ("Not an AppleDisk"); // impossible
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
package com.bytezone.diskbrowser.gui;
|
package com.bytezone.diskbrowser.gui;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import javax.swing.Action;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.KeyStroke;
|
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
|
|
||||||
@ -18,17 +12,12 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||||||
//-----------------------------------------------------------------------------------//
|
//-----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
AppleFileSource appleFileSource;
|
AppleFileSource appleFileSource;
|
||||||
private JCheckBox formatted = new JCheckBox ("Formatted");
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
SaveFileAction ()
|
SaveFileAction ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("Save file...", "Save currently selected file", "Save File");
|
super ("Save file...", "Save currently selected file", "Save File");
|
||||||
|
|
||||||
fileChooser.setAccessory (formatted);
|
|
||||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
|
||||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_S, mask));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -42,18 +31,8 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formatted.isSelected ())
|
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
||||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".txt"));
|
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
||||||
else
|
|
||||||
setSelectedFile (new File (appleFileSource.getUniqueName () + ".bin"));
|
|
||||||
|
|
||||||
if (fileChooser.showSaveDialog (null) != JFileChooser.APPROVE_OPTION)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (formatted.isSelected ())
|
|
||||||
saveBuffer (appleFileSource.getDataSource ().getText ().getBytes ());
|
|
||||||
else
|
|
||||||
saveBuffer (appleFileSource.getDataSource ().getBuffer ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -62,8 +41,8 @@ class SaveFileAction extends AbstractSaveAction implements FileSelectionListener
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.appleFileSource = event.appleFileSource;
|
this.appleFileSource = event.appleFileSource;
|
||||||
|
setEnabled (
|
||||||
setEnabled (appleFileSource != null && appleFileSource.getDataSource () != null
|
event.appleFileSource != null && event.appleFileSource.getDataSource () != null
|
||||||
&& appleFileSource.getDataSource ().getBuffer () != null);
|
&& event.appleFileSource.getDataSource ().getBuffer () != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
@ -42,9 +41,7 @@ class SaveSectorsAction extends AbstractSaveAction implements SectorSelectionLis
|
|||||||
blocks.size () == 1 ? disk.readBlock (blocks.get (0)) : disk.readBlocks (blocks);
|
blocks.size () == 1 ? disk.readBlock (blocks.get (0)) : disk.readBlocks (blocks);
|
||||||
|
|
||||||
setSelectedFile (new File ("SavedSectors.bin"));
|
setSelectedFile (new File ("SavedSectors.bin"));
|
||||||
|
saveBuffer (buffer);
|
||||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
|
||||||
saveBuffer (buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -10,20 +10,20 @@ import com.bytezone.diskbrowser.prodos.write.DiskFullException;
|
|||||||
import com.bytezone.diskbrowser.prodos.write.FileAlreadyExistsException;
|
import com.bytezone.diskbrowser.prodos.write.FileAlreadyExistsException;
|
||||||
import com.bytezone.diskbrowser.prodos.write.ProdosDisk;
|
import com.bytezone.diskbrowser.prodos.write.ProdosDisk;
|
||||||
import com.bytezone.diskbrowser.prodos.write.VolumeCatalogFullException;
|
import com.bytezone.diskbrowser.prodos.write.VolumeCatalogFullException;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
public class Binary2
|
public class Binary2
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final String UNDERLINE =
|
private static final String UNDERLINE =
|
||||||
"------------------------------------------------------" + "-----------------------";
|
"------------------------------------------------------"
|
||||||
|
+ "-----------------------";
|
||||||
|
|
||||||
private Binary2Header binary2Header;
|
Binary2Header binary2Header;
|
||||||
private byte[] buffer;
|
byte[] buffer;
|
||||||
private List<Binary2Header> headers = new ArrayList<> ();
|
List<Binary2Header> headers = new ArrayList<> ();
|
||||||
private int totalBlocks;
|
int totalBlocks;
|
||||||
private String fileName;
|
String fileName;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public Binary2 (Path path) throws IOException
|
public Binary2 (Path path) throws IOException
|
||||||
@ -43,17 +43,18 @@ public class Binary2
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
binary2Header = new Binary2Header (buffer, ptr);
|
binary2Header = new Binary2Header (buffer, ptr);
|
||||||
|
System.out.println (binary2Header);
|
||||||
headers.add (binary2Header);
|
headers.add (binary2Header);
|
||||||
|
|
||||||
totalBlocks += binary2Header.totalBlocks;
|
totalBlocks += binary2Header.totalBlocks;
|
||||||
ptr += ((binary2Header.eof - 1) / 128 + 2) * 128;
|
ptr += ((binary2Header.eof - 1) / 128 + 1) * 128 + 128;
|
||||||
} while (binary2Header.filesToFollow > 0);
|
} while (binary2Header.filesToFollow > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public byte[] getDiskBuffer ()
|
public byte[] getDiskBuffer () throws DiskFullException, VolumeCatalogFullException,
|
||||||
throws DiskFullException, VolumeCatalogFullException, FileAlreadyExistsException, IOException
|
FileAlreadyExistsException, IOException
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
ProdosDisk disk = new ProdosDisk (800, "DiskBrowser");
|
ProdosDisk disk = new ProdosDisk (800, "DiskBrowser");
|
||||||
@ -63,19 +64,9 @@ public class Binary2
|
|||||||
byte[] dataBuffer = new byte[header.eof]; // this sux
|
byte[] dataBuffer = new byte[header.eof]; // this sux
|
||||||
System.arraycopy (buffer, header.ptr + 128, dataBuffer, 0, dataBuffer.length);
|
System.arraycopy (buffer, header.ptr + 128, dataBuffer, 0, dataBuffer.length);
|
||||||
|
|
||||||
if (header.compressed && dataBuffer[0] == 0x76 && dataBuffer[1] == (byte) 0xFF)
|
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
||||||
{
|
header.modified, dataBuffer, header.eof);
|
||||||
String name = Utility.getCString (dataBuffer, 4);
|
|
||||||
|
|
||||||
Squeeze squeeze = new Squeeze ();
|
|
||||||
byte[] tmp = squeeze.unSqueeze (dataBuffer);
|
|
||||||
|
|
||||||
disk.addFile (name, header.fileType, header.auxType, header.created, header.modified, tmp,
|
|
||||||
tmp.length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
|
|
||||||
header.modified, dataBuffer, header.eof);
|
|
||||||
}
|
}
|
||||||
disk.close ();
|
disk.close ();
|
||||||
|
|
||||||
@ -89,12 +80,12 @@ public class Binary2
|
|||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
text.append (
|
text.append (String.format (
|
||||||
String.format (" %-15.15s Files:%5d%n%n",
|
" %-15.15s Files:%5d%n%n",
|
||||||
fileName, headers.size ()));
|
fileName, headers.size ()));
|
||||||
|
|
||||||
text.append (
|
text.append (" Name Type Auxtyp Modified"
|
||||||
" Name Type Auxtyp Modified" + " Fmat Length\n");
|
+ " Fmat Length\n");
|
||||||
|
|
||||||
text.append (String.format ("%s%n", UNDERLINE));
|
text.append (String.format ("%s%n", UNDERLINE));
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@ public class Binary2Header
|
|||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern ("dd-LLL-yy HH:mm");
|
||||||
static String[] osTypes = { "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal",
|
static String[] osTypes =
|
||||||
"Macintosh MFS", "Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
{ "Prodos", "DOS 3.3", "Reserved", "DOS 3.2 or 3.1", "Pascal", "Macintosh MFS",
|
||||||
"ISO 9660 (CD-ROM)", "AppleShare" };
|
"Macintosh HFS", "Lisa", "CPM", "Reserved", "MS-DOS", "High Sierra (CD-ROM)",
|
||||||
|
"ISO 9660 (CD-ROM)", "AppleShare" };
|
||||||
|
|
||||||
int ptr;
|
int ptr;
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
@ -88,8 +89,8 @@ public class Binary2Header
|
|||||||
public String getLine ()
|
public String getLine ()
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format (" %-33s %3s $%04X %s unc %7d", fileName, fileTypes[fileType],
|
return String.format (" %-33s %3s $%04X %s unc %7d", fileName,
|
||||||
auxType, modified.format (formatter), eof);
|
fileTypes[fileType], auxType, modified.format (formatter), eof);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
@ -116,13 +117,12 @@ public class Binary2Header
|
|||||||
text.append (String.format ("Prodos storage type ... %02X%n", prodos16storageType));
|
text.append (String.format ("Prodos storage type ... %02X%n", prodos16storageType));
|
||||||
text.append (String.format ("Prodos total blocks ... %02X%n", prodos16totalBlocks));
|
text.append (String.format ("Prodos total blocks ... %02X%n", prodos16totalBlocks));
|
||||||
text.append (String.format ("Prodos eof ............ %06X %<,d%n", prodos16eof));
|
text.append (String.format ("Prodos eof ............ %06X %<,d%n", prodos16eof));
|
||||||
text.append (String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
text.append (
|
||||||
text.append (String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
String.format ("Disk space needed ..... %08X %<,d%n", diskSpaceRequired));
|
||||||
|
text.append (
|
||||||
|
String.format ("OS type ............... %02X %s%n", osType, osTypes[osType]));
|
||||||
text.append (String.format ("Native file type ...... %02X%n", nativeFileType));
|
text.append (String.format ("Native file type ...... %02X%n", nativeFileType));
|
||||||
text.append (String.format ("Data flags ............ %02X%n", dataFlags));
|
text.append (String.format ("Data flags ............ %02X%n", dataFlags));
|
||||||
text.append (String.format (" compressed .......... %s%n", compressed));
|
|
||||||
text.append (String.format (" encrypted ........... %s%n", encrypted));
|
|
||||||
text.append (String.format (" sparse .............. %s%n", sparsePacked));
|
|
||||||
text.append (String.format ("Version ............... %02X%n", version));
|
text.append (String.format ("Version ............... %02X%n", version));
|
||||||
text.append (String.format ("Following files ....... %02X%n", filesToFollow));
|
text.append (String.format ("Following files ....... %02X%n", filesToFollow));
|
||||||
|
|
||||||
|
@ -1,125 +0,0 @@
|
|||||||
package com.bytezone.diskbrowser.nufx;
|
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
|
||||||
|
|
||||||
// see http://fileformats.archiveteam.org/wiki/Squeeze
|
|
||||||
// see http://fileformats.archiveteam.org/wiki/RLE90
|
|
||||||
// -----------------------------------------------------------------------------------//
|
|
||||||
public class Squeeze
|
|
||||||
// -----------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
private static final byte[] Squeeze = { 0x76, (byte) 0xFF };
|
|
||||||
private static int RLE_DELIMITER = 0x90;
|
|
||||||
private static int EOF_TOKEN = 0x100;
|
|
||||||
|
|
||||||
private int bits;
|
|
||||||
private int bitPos = 7; // trigger the first read
|
|
||||||
private int ptr;
|
|
||||||
private byte[] buffer;
|
|
||||||
private Node[] nodes;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public byte[] unSqueeze (byte[] buffer)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
if (!Utility.isMagic (buffer, 0, Squeeze))
|
|
||||||
throw new FileFormatException ("Not Squeeze format");
|
|
||||||
|
|
||||||
byte[] uncompressed = new byte[buffer.length * 3];
|
|
||||||
int uncPtr = 0;
|
|
||||||
|
|
||||||
int fileChecksum = Utility.getShort (buffer, 2);
|
|
||||||
String fileName = Utility.getCString (buffer, 4);
|
|
||||||
|
|
||||||
ptr = fileName.length () + 5;
|
|
||||||
int nodeCount = Utility.getShort (buffer, ptr);
|
|
||||||
ptr += 2;
|
|
||||||
|
|
||||||
nodes = new Node[nodeCount];
|
|
||||||
this.buffer = buffer;
|
|
||||||
|
|
||||||
for (int i = 0; i < nodes.length; i++)
|
|
||||||
{
|
|
||||||
int left = Utility.getSignedShort (buffer, ptr);
|
|
||||||
int right = Utility.getSignedShort (buffer, ptr + 2);
|
|
||||||
nodes[i] = new Node (left, right);
|
|
||||||
ptr += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean repeating = false;
|
|
||||||
int lastVal = 0;
|
|
||||||
int sum = 0;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int val = decodeSymbol ();
|
|
||||||
if (val == EOF_TOKEN)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (repeating)
|
|
||||||
{
|
|
||||||
repeating = false;
|
|
||||||
|
|
||||||
if (val == 0) // flag indicating a single RLE_DELIMITER
|
|
||||||
{
|
|
||||||
lastVal = RLE_DELIMITER;
|
|
||||||
val = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (--val != 0)
|
|
||||||
{
|
|
||||||
sum += lastVal;
|
|
||||||
uncompressed[uncPtr++] = (byte) lastVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (val == RLE_DELIMITER)
|
|
||||||
repeating = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastVal = val;
|
|
||||||
sum += lastVal;
|
|
||||||
uncompressed[uncPtr++] = (byte) lastVal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sum & 0xFFFF) != fileChecksum)
|
|
||||||
System.out.printf ("Checksum mismatch : %04X %04X%n", fileChecksum, sum & 0xFFFF);
|
|
||||||
|
|
||||||
byte[] uncompressedBuffer = new byte[uncPtr];
|
|
||||||
System.arraycopy (uncompressed, 0, uncompressedBuffer, 0, uncompressedBuffer.length);
|
|
||||||
|
|
||||||
return uncompressedBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
private int decodeSymbol ()
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
int val = 0;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (++bitPos > 7)
|
|
||||||
{
|
|
||||||
bits = buffer[ptr++];
|
|
||||||
bitPos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
val = (bits & 1) == 0 ? nodes[val].left : nodes[val].right;
|
|
||||||
bits >>>= 1;
|
|
||||||
|
|
||||||
if (val < 0)
|
|
||||||
return -++val; // increment and make positive
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
record Node (int left, int right)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.bytezone.diskbrowser.pascal;
|
package com.bytezone.diskbrowser.pascal;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
@ -29,6 +30,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static final int CATALOG_ENTRY_SIZE = 26;
|
static final int CATALOG_ENTRY_SIZE = 26;
|
||||||
|
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||||
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||||
private final VolumeEntry volumeEntry;
|
private final VolumeEntry volumeEntry;
|
||||||
private final PascalCatalogSector diskCatalogSector;
|
private final PascalCatalogSector diskCatalogSector;
|
||||||
@ -233,6 +235,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
}
|
}
|
||||||
|
|
||||||
int lastByte = Utility.getShort (buffer, ptr + 22);
|
int lastByte = Utility.getShort (buffer, ptr + 22);
|
||||||
|
// GregorianCalendar date = Utility.getPascalDate (buffer, 24);
|
||||||
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
||||||
String dateString = localDate == null ? ""
|
String dateString = localDate == null ? ""
|
||||||
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
||||||
|
@ -17,7 +17,6 @@ public abstract class DefaultAction extends AbstractAction
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (text);
|
super (text);
|
||||||
|
|
||||||
this.baseURL = null;
|
this.baseURL = null;
|
||||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||||
}
|
}
|
||||||
@ -27,7 +26,6 @@ public abstract class DefaultAction extends AbstractAction
|
|||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (text);
|
super (text);
|
||||||
|
|
||||||
this.baseURL = baseURL;
|
this.baseURL = baseURL;
|
||||||
putValue (Action.SHORT_DESCRIPTION, tip);
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
||||||
}
|
}
|
||||||
@ -41,7 +39,6 @@ public abstract class DefaultAction extends AbstractAction
|
|||||||
System.out.println ("Base URL not set");
|
System.out.println ("Base URL not set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = this.getClass ().getResource (baseURL + iconName);
|
URL url = this.getClass ().getResource (baseURL + iconName);
|
||||||
if (url != null)
|
if (url != null)
|
||||||
putValue (iconType, new ImageIcon (url));
|
putValue (iconType, new ImageIcon (url));
|
||||||
|
@ -41,7 +41,7 @@ public final class Utility
|
|||||||
private static MathContext mathContext8 = new MathContext (15);
|
private static MathContext mathContext8 = new MathContext (15);
|
||||||
|
|
||||||
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
|
||||||
"d13", "sdk", "shk", "bxy", "bny", "bqy", "woz", "img", "dimg");
|
"d13", "sdk", "shk", "bxy", "bny", "woz", "img", "dimg");
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
private Utility ()
|
private Utility ()
|
||||||
@ -454,19 +454,6 @@ public final class Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
public static String getCString (byte[] buffer, int offset)
|
|
||||||
// ---------------------------------------------------------------------------------//
|
|
||||||
{
|
|
||||||
int length = 0;
|
|
||||||
int ptr = offset;
|
|
||||||
|
|
||||||
while (buffer[ptr++] != 0)
|
|
||||||
++length;
|
|
||||||
|
|
||||||
return new String (buffer, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public static int getWizLong (byte[] buffer, int offset)
|
public static int getWizLong (byte[] buffer, int offset)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
Loading…
Reference in New Issue
Block a user