mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-18 05:30:29 +00:00
save sdk disks
This commit is contained in:
parent
2208b8f277
commit
220a2f1cf9
@ -179,6 +179,11 @@ public class DirectoryEntry implements AppleFileSource
|
||||
|
||||
DirectoryEntry entry = recordsUsed == 0x80 ? entries.get (entries.size () - 1) : this;
|
||||
int len = (entry.extent * 128 + entry.recordsUsed) * 128;
|
||||
if (len > buffer.length)
|
||||
{
|
||||
System.out.println ("too big"); // see tdbt12d1.sdk
|
||||
len = buffer.length;
|
||||
}
|
||||
|
||||
byte[] exactBuffer = new byte[len];
|
||||
System.arraycopy (buffer, 0, exactBuffer, 0, len);
|
||||
|
@ -185,11 +185,18 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
root.setUserObject (afs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getOriginalPath ()
|
||||
{
|
||||
return originalPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbsolutePath ()
|
||||
{
|
||||
if (originalPath != null)
|
||||
return originalPath.toString ();
|
||||
|
||||
return disk.getFile ().getAbsolutePath ();
|
||||
}
|
||||
|
||||
@ -198,13 +205,21 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||
{
|
||||
if (originalPath != null)
|
||||
return originalPath.toString ();
|
||||
|
||||
String home = System.getProperty ("user.home");
|
||||
String path = disk.getFile ().getAbsolutePath ();
|
||||
if (path.startsWith (home))
|
||||
return "~" + path.substring (home.length ());
|
||||
|
||||
return disk.getFile ().getAbsolutePath ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempDisk ()
|
||||
{
|
||||
return originalPath != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName ()
|
||||
{
|
||||
|
@ -258,4 +258,16 @@ public class DualDosDisk implements FormattedDisk
|
||||
{
|
||||
return disks[currentDisk].getName ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempDisk ()
|
||||
{
|
||||
return disks[currentDisk].isTempDisk ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getOriginalPath ()
|
||||
{
|
||||
return disks[currentDisk].getOriginalPath ();
|
||||
}
|
||||
}
|
@ -68,6 +68,10 @@ public interface FormattedDisk
|
||||
|
||||
public void setOriginalPath (Path path);
|
||||
|
||||
public Path getOriginalPath ();
|
||||
|
||||
public boolean isTempDisk ();
|
||||
|
||||
// VTOC flags sector as free, but it is in use by a file
|
||||
public int falsePositiveBlocks ();
|
||||
|
||||
|
@ -257,7 +257,7 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
}
|
||||
if (catalogBlocks > 0)
|
||||
{
|
||||
disk.setInterleave (0);
|
||||
disk.setInterleave (1);
|
||||
return true;
|
||||
}
|
||||
if (cb2 > 0)
|
||||
@ -297,7 +297,6 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
|
||||
if (buffer[53] != 16 && buffer[53] != 13) // tracks per sector
|
||||
{
|
||||
System.out.printf ("%02X tracks per sector%n", buffer[53]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ public class MenuHandler
|
||||
private static final String PREFS_PALETTE = "palette";
|
||||
|
||||
FormattedDisk currentDisk;
|
||||
private final SaveTempFileAction saveTempFileAction = new SaveTempFileAction ();
|
||||
|
||||
JMenuBar menuBar = new JMenuBar ();
|
||||
JMenu fileMenu = new JMenu ("File");
|
||||
@ -42,6 +43,7 @@ public class MenuHandler
|
||||
final JMenuItem rootItem = new JMenuItem ("Set root folder...");
|
||||
final JMenuItem refreshTreeItem = new JMenuItem ("Refresh current tree");
|
||||
JMenuItem executeDiskItem;
|
||||
final JMenuItem saveDiskItem = new JMenuItem ("Save converted disk as...");
|
||||
final JMenuItem printItem = new JMenuItem ("Print output panel...");
|
||||
final JMenuItem closeTabItem = new JMenuItem ();
|
||||
final JMenuItem duplicateItem = new JMenuItem ();
|
||||
@ -78,6 +80,7 @@ public class MenuHandler
|
||||
fileMenu.add (rootItem);
|
||||
fileMenu.addSeparator ();
|
||||
fileMenu.add (refreshTreeItem);
|
||||
fileMenu.add (saveDiskItem);
|
||||
|
||||
addLauncherMenu ();
|
||||
|
||||
@ -144,6 +147,8 @@ public class MenuHandler
|
||||
interleaveGroup.add (interleave1Item);
|
||||
interleaveGroup.add (interleave2Item);
|
||||
interleaveGroup.add (interleave3Item);
|
||||
|
||||
saveDiskItem.setAction (saveTempFileAction);
|
||||
}
|
||||
|
||||
void addHelpMenuAction (Action action, String functionName)
|
||||
@ -279,5 +284,8 @@ public class MenuHandler
|
||||
((InterleaveAction) interleave2Item.getAction ()).setDisk (currentDisk);
|
||||
((InterleaveAction) interleave3Item.getAction ()).setDisk (currentDisk);
|
||||
}
|
||||
|
||||
saveDiskItem.setEnabled (disk.isTempDisk ());
|
||||
saveTempFileAction.setDisk (disk);
|
||||
}
|
||||
}
|
@ -20,9 +20,10 @@ class PrintAction extends DefaultAction
|
||||
{
|
||||
super ("Print...", "Print the contents of the output panel",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask ();
|
||||
int mask = Toolkit.getDefaultToolkit ().getMenuShortcutKeyMaskEx ();
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_P, mask));
|
||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_P);
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
setIcon (Action.SMALL_ICON, "printer_16.png");
|
||||
|
@ -15,10 +15,10 @@ class RefreshTreeAction extends DefaultAction
|
||||
public RefreshTreeAction (CatalogPanel owner)
|
||||
{
|
||||
super ("Refresh current tree", "Makes newly added/modified disks available",
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt R"));
|
||||
"/com/bytezone/diskbrowser/icons/");
|
||||
// putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt R"));
|
||||
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_F5, 0));
|
||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_R);
|
||||
// putValue (Action.MNEMONIC_KEY, KeyEvent.VK_R);
|
||||
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_F5);
|
||||
this.owner = owner;
|
||||
|
||||
|
49
src/com/bytezone/diskbrowser/gui/SaveTempFileAction.java
Normal file
49
src/com/bytezone/diskbrowser/gui/SaveTempFileAction.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.bytezone.diskbrowser.gui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.bytezone.common.DefaultAction;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
public class SaveTempFileAction extends DefaultAction
|
||||
{
|
||||
FormattedDisk disk;
|
||||
|
||||
public SaveTempFileAction ()
|
||||
{
|
||||
super ("Save converted file...", "Save converted file");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent evt)
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser ();
|
||||
fileChooser.setDialogTitle ("Save converted disk");
|
||||
String name = disk.getName ();
|
||||
fileChooser.setSelectedFile (new File (name + ".dsk"));
|
||||
if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile ();
|
||||
try
|
||||
{
|
||||
Files.copy (disk.getDisk ().getFile ().toPath (), file.toPath ());
|
||||
JOptionPane.showMessageDialog (null, "Disk saved");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setDisk (FormattedDisk disk)
|
||||
{
|
||||
this.disk = disk;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user