This commit is contained in:
parent
1b0e78bd80
commit
50608b9c43
|
@ -28,6 +28,9 @@ import java.util.List;
|
||||||
* <p>
|
* <p>
|
||||||
* Date Created: Mar 2, 2003
|
* Date Created: Mar 2, 2003
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public interface DirectoryEntry {
|
public interface DirectoryEntry {
|
||||||
/**
|
/**
|
||||||
|
@ -37,17 +40,17 @@ public interface DirectoryEntry {
|
||||||
* return value should always be a list - a directory
|
* return value should always be a list - a directory
|
||||||
* with 0 entries returns an empty list.
|
* with 0 entries returns an empty list.
|
||||||
*/
|
*/
|
||||||
public List<FileEntry> getFiles();
|
public List<FileEntry> getFiles() throws DiskException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new FileEntry.
|
* Create a new FileEntry.
|
||||||
*/
|
*/
|
||||||
public FileEntry createFile() throws DiskFullException;
|
public FileEntry createFile() throws DiskException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new DirectoryEntry.
|
* Create a new DirectoryEntry.
|
||||||
*/
|
*/
|
||||||
public DirectoryEntry createDirectory(String name) throws DiskFullException;
|
public DirectoryEntry createDirectory(String name) throws DiskException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify if additional directories can be created. This
|
* Identify if additional directories can be created. This
|
||||||
|
@ -56,7 +59,7 @@ public interface DirectoryEntry {
|
||||||
* to writing.
|
* to writing.
|
||||||
*/
|
*/
|
||||||
public boolean canCreateDirectories();
|
public boolean canCreateDirectories();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if this disk image can create a file.
|
* Indicates if this disk image can create a file.
|
||||||
* If not, the reason may be as simple as it has not beem implemented
|
* If not, the reason may be as simple as it has not beem implemented
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* AppleCommander - An Apple ][ image utility.
|
||||||
|
* Copyright (C) 2002 by Robert Greene
|
||||||
|
* robgreene at users.sourceforge.net
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
package com.webcodepro.applecommander.storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DiskCorruptException is thrown during the disk's data structures are corrupted
|
||||||
|
* beyound hope of automatic recovering.
|
||||||
|
* <br>
|
||||||
|
* Created on Nov 30, 2017.
|
||||||
|
* @author Lisias Toledo
|
||||||
|
*/
|
||||||
|
public class DiskCorruptException extends DiskException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for DiskFullException.
|
||||||
|
*/
|
||||||
|
public DiskCorruptException(String description) {
|
||||||
|
super(description);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* AppleCommander - An Apple ][ image utility.
|
||||||
|
* Copyright (C) 2002 by Robert Greene
|
||||||
|
* robgreene at users.sourceforge.net
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
package com.webcodepro.applecommander.storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A DiskFullException is thrown during a write operation when the file
|
||||||
|
* being written will not fit on the disk.
|
||||||
|
* <br>
|
||||||
|
* Created on Dec 23, 2002.
|
||||||
|
* @author Rob Greene
|
||||||
|
*/
|
||||||
|
public class DiskException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for DiskFullException.
|
||||||
|
*/
|
||||||
|
public DiskException(String description) {
|
||||||
|
super(description);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,8 +25,11 @@ package com.webcodepro.applecommander.storage;
|
||||||
* <br>
|
* <br>
|
||||||
* Created on Dec 23, 2002.
|
* Created on Dec 23, 2002.
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class DiskFullException extends Exception {
|
public class DiskFullException extends DiskException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
private static final long serialVersionUID = 0xFFFFFFFF80000000L;
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,13 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
|
||||||
* Returns a null if specific filename is not located.
|
* Returns a null if specific filename is not located.
|
||||||
*/
|
*/
|
||||||
public FileEntry getFile(String filename) {
|
public FileEntry getFile(String filename) {
|
||||||
List files = getFiles();
|
List files;
|
||||||
|
try {
|
||||||
|
files = getFiles();
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
files = new ArrayList<>();
|
||||||
|
}
|
||||||
return getFile(files, filename.trim());
|
return getFile(files, filename.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,11 +288,13 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (int i=0; i<files.size(); i++) {
|
for (int i=0; i<files.size(); i++) {
|
||||||
FileEntry entry = (FileEntry) files.get(i);
|
FileEntry entry = (FileEntry) files.get(i);
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) try {
|
||||||
theFileEntry = getFile(
|
theFileEntry = getFile(
|
||||||
((DirectoryEntry)entry).getFiles(), filename);
|
((DirectoryEntry)entry).getFiles(), filename);
|
||||||
if (theFileEntry != null) break;
|
if (theFileEntry != null) break;
|
||||||
}
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
String otherFilename = entry.getFilename();
|
String otherFilename = entry.getFilename();
|
||||||
if (otherFilename != null) otherFilename = otherFilename.trim();
|
if (otherFilename != null) otherFilename = otherFilename.trim();
|
||||||
if (filename.equalsIgnoreCase(otherFilename)) {
|
if (filename.equalsIgnoreCase(otherFilename)) {
|
||||||
|
|
|
@ -20,9 +20,13 @@
|
||||||
package com.webcodepro.applecommander.storage.os.dos33;
|
package com.webcodepro.applecommander.storage.os.dos33;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskException;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskCorruptException;
|
||||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||||
import com.webcodepro.applecommander.storage.FileEntry;
|
import com.webcodepro.applecommander.storage.FileEntry;
|
||||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||||
|
@ -36,6 +40,9 @@ import com.webcodepro.applecommander.util.TextBundle;
|
||||||
* <p>
|
* <p>
|
||||||
* Date created: Oct 4, 2002 12:29:23 AM
|
* Date created: Oct 4, 2002 12:29:23 AM
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class DosFormatDisk extends FormattedDisk {
|
public class DosFormatDisk extends FormattedDisk {
|
||||||
private TextBundle textBundle = StorageBundle.getInstance();
|
private TextBundle textBundle = StorageBundle.getInstance();
|
||||||
|
@ -132,14 +139,22 @@ public class DosFormatDisk extends FormattedDisk {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of files.
|
* Retrieve a list of files.
|
||||||
|
* @throws DiskException
|
||||||
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
|
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
|
||||||
*/
|
*/
|
||||||
public List<FileEntry> getFiles() {
|
public List<FileEntry> getFiles() throws DiskException {
|
||||||
List<FileEntry> list = new ArrayList<>();
|
List<FileEntry> list = new ArrayList<>();
|
||||||
byte[] vtoc = readVtoc();
|
byte[] vtoc = readVtoc();
|
||||||
int track = AppleUtil.getUnsignedByte(vtoc[1]);
|
int track = AppleUtil.getUnsignedByte(vtoc[1]);
|
||||||
int sector = AppleUtil.getUnsignedByte(vtoc[2]);
|
int sector = AppleUtil.getUnsignedByte(vtoc[2]);
|
||||||
|
final Map<Integer,Map<Integer,Boolean>> visits = new HashMap<>();
|
||||||
while (sector != 0) { // bug fix: iterate through all catalog _sectors_
|
while (sector != 0) { // bug fix: iterate through all catalog _sectors_
|
||||||
|
|
||||||
|
// Prevents a recursive catalog crawling.
|
||||||
|
if ( !visits.containsKey(track) ) visits.put(track, new HashMap<Integer,Boolean>());
|
||||||
|
if ( visits.get(track).containsKey(sector)) throw new DiskCorruptException("Recursive Directory structure detected.");
|
||||||
|
else visits.get(track).put(sector, Boolean.TRUE);
|
||||||
|
|
||||||
byte[] catalogSector = readSector(track, sector);
|
byte[] catalogSector = readSector(track, sector);
|
||||||
int offset = 0x0b;
|
int offset = 0x0b;
|
||||||
while (offset < 0xff) { // iterate through all entries
|
while (offset < 0xff) { // iterate through all entries
|
||||||
|
|
|
@ -22,6 +22,7 @@ package com.webcodepro.applecommander.storage.os.prodos;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskException;
|
||||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||||
import com.webcodepro.applecommander.storage.FileEntry;
|
import com.webcodepro.applecommander.storage.FileEntry;
|
||||||
import com.webcodepro.applecommander.storage.StorageBundle;
|
import com.webcodepro.applecommander.storage.StorageBundle;
|
||||||
|
@ -32,21 +33,24 @@ import com.webcodepro.applecommander.util.TextBundle;
|
||||||
* <p>
|
* <p>
|
||||||
* Date Created: Mar 2, 2003
|
* Date Created: Mar 2, 2003
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEntry {
|
public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEntry {
|
||||||
private TextBundle textBundle = StorageBundle.getInstance();
|
private TextBundle textBundle = StorageBundle.getInstance();
|
||||||
private ProdosSubdirectoryHeader subdirectoryHeader;
|
private ProdosSubdirectoryHeader subdirectoryHeader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ProdosDirectoryEntry.
|
* Constructor for ProdosDirectoryEntry.
|
||||||
*/
|
*/
|
||||||
public ProdosDirectoryEntry(ProdosFormatDisk disk, int block, int offset,
|
public ProdosDirectoryEntry(ProdosFormatDisk disk, int block, int offset,
|
||||||
ProdosSubdirectoryHeader subdirectoryHeader) {
|
ProdosSubdirectoryHeader subdirectoryHeader) {
|
||||||
super(disk, block, offset);
|
super(disk, block, offset);
|
||||||
this.subdirectoryHeader = subdirectoryHeader;
|
this.subdirectoryHeader = subdirectoryHeader;
|
||||||
subdirectoryHeader.setProdosDirectoryEntry(this);
|
subdirectoryHeader.setProdosDirectoryEntry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the subdirectory header.
|
* Get the subdirectory header.
|
||||||
*/
|
*/
|
||||||
|
@ -60,8 +64,9 @@ public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEn
|
||||||
* value should be null. If this a directory, the
|
* value should be null. If this a directory, the
|
||||||
* return value should always be a list - a directory
|
* return value should always be a list - a directory
|
||||||
* with 0 entries returns an empty list.
|
* with 0 entries returns an empty list.
|
||||||
|
* @throws DiskException
|
||||||
*/
|
*/
|
||||||
public List<FileEntry> getFiles() {
|
public List<FileEntry> getFiles() throws DiskException {
|
||||||
return getDisk().getFiles(getSubdirectoryHeader().getFileEntryBlock());
|
return getDisk().getFiles(getSubdirectoryHeader().getFileEntryBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,14 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskException;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskCorruptException;
|
||||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
import com.webcodepro.applecommander.storage.DiskFullException;
|
||||||
import com.webcodepro.applecommander.storage.FileEntry;
|
import com.webcodepro.applecommander.storage.FileEntry;
|
||||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||||
|
@ -40,6 +44,9 @@ import com.webcodepro.applecommander.util.TextBundle;
|
||||||
* <p>
|
* <p>
|
||||||
* Date created: Oct 3, 2002 11:45:25 PM
|
* Date created: Oct 3, 2002 11:45:25 PM
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class ProdosFormatDisk extends FormattedDisk {
|
public class ProdosFormatDisk extends FormattedDisk {
|
||||||
private TextBundle textBundle = StorageBundle.getInstance();
|
private TextBundle textBundle = StorageBundle.getInstance();
|
||||||
|
@ -255,9 +262,10 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of files.
|
* Retrieve a list of files.
|
||||||
|
* @throws DiskException
|
||||||
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
|
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
|
||||||
*/
|
*/
|
||||||
public List<FileEntry> getFiles() {
|
public List<FileEntry> getFiles() throws DiskException {
|
||||||
return getFiles(VOLUME_DIRECTORY_BLOCK);
|
return getFiles(VOLUME_DIRECTORY_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,9 +273,14 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||||
* Build a list of files, starting in the given block number.
|
* Build a list of files, starting in the given block number.
|
||||||
* This works for the master as well as the subdirectories.
|
* This works for the master as well as the subdirectories.
|
||||||
*/
|
*/
|
||||||
protected List<FileEntry> getFiles(int blockNumber) {
|
protected List<FileEntry> getFiles(int blockNumber) throws DiskException {
|
||||||
List<FileEntry> files = new ArrayList<>();
|
List<FileEntry> files = new ArrayList<>();
|
||||||
|
final Map<Integer,Boolean> visits = new HashMap<>();
|
||||||
while (blockNumber != 0) {
|
while (blockNumber != 0) {
|
||||||
|
// Prevents a recursive catalog crawling.
|
||||||
|
if ( visits.containsKey(blockNumber)) throw new DiskCorruptException("Recursive Directory structure detected.");
|
||||||
|
else visits.put(blockNumber, Boolean.TRUE);
|
||||||
|
|
||||||
byte[] block = readBlock(blockNumber);
|
byte[] block = readBlock(blockNumber);
|
||||||
int offset = 4;
|
int offset = 4;
|
||||||
while (offset+ProdosCommonEntry.ENTRY_LENGTH < BLOCK_SIZE) {
|
while (offset+ProdosCommonEntry.ENTRY_LENGTH < BLOCK_SIZE) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||||
import com.webcodepro.applecommander.storage.Disk;
|
import com.webcodepro.applecommander.storage.Disk;
|
||||||
import com.webcodepro.applecommander.storage.DiskFullException;
|
import com.webcodepro.applecommander.storage.DiskException;
|
||||||
import com.webcodepro.applecommander.storage.FileEntry;
|
import com.webcodepro.applecommander.storage.FileEntry;
|
||||||
import com.webcodepro.applecommander.storage.FileFilter;
|
import com.webcodepro.applecommander.storage.FileFilter;
|
||||||
import com.webcodepro.applecommander.storage.FormattedDisk;
|
import com.webcodepro.applecommander.storage.FormattedDisk;
|
||||||
|
@ -85,6 +85,9 @@ import com.webcodepro.applecommander.util.TextBundle;
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author John B. Matthews
|
* @author John B. Matthews
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class ac {
|
public class ac {
|
||||||
private static TextBundle textBundle = UiBundle.getInstance();
|
private static TextBundle textBundle = UiBundle.getInstance();
|
||||||
|
@ -154,7 +157,7 @@ public class ac {
|
||||||
* Put fileName from the local filesytem into the file named fileOnImageName on the disk named imageName;
|
* Put fileName from the local filesytem into the file named fileOnImageName on the disk named imageName;
|
||||||
* Note: only volume level supported; input size unlimited.
|
* Note: only volume level supported; input size unlimited.
|
||||||
*/
|
*/
|
||||||
public static void putFile(String fileName, String imageName, String fileOnImageName, String fileType, String address) throws IOException, DiskFullException {
|
public static void putFile(String fileName, String imageName, String fileOnImageName, String fileType, String address) throws IOException, DiskException {
|
||||||
Name name = new Name(fileOnImageName);
|
Name name = new Name(fileOnImageName);
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
if (!file.canRead())
|
if (!file.canRead())
|
||||||
|
@ -188,7 +191,7 @@ public class ac {
|
||||||
* Note: only volume level supported; input size unlimited.
|
* Note: only volume level supported; input size unlimited.
|
||||||
*/
|
*/
|
||||||
static void putFile(String imageName, Name name, String fileType,
|
static void putFile(String imageName, Name name, String fileType,
|
||||||
String address) throws IOException, DiskFullException {
|
String address) throws IOException, DiskException {
|
||||||
|
|
||||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||||
byte[] inb = new byte[1024];
|
byte[] inb = new byte[1024];
|
||||||
|
@ -225,7 +228,7 @@ public class ac {
|
||||||
* Assume a cc65 style four-byte header with start address in bytes 0-1.
|
* Assume a cc65 style four-byte header with start address in bytes 0-1.
|
||||||
*/
|
*/
|
||||||
public static void putCC65(String fileName, String imageName, String fileOnImageName, String fileType)
|
public static void putCC65(String fileName, String imageName, String fileOnImageName, String fileType)
|
||||||
throws IOException, DiskFullException {
|
throws IOException, DiskException {
|
||||||
|
|
||||||
byte[] header = new byte[4];
|
byte[] header = new byte[4];
|
||||||
if (System.in.read(header, 0, 4) == 4) {
|
if (System.in.read(header, 0, 4) == 4) {
|
||||||
|
@ -239,7 +242,7 @@ public class ac {
|
||||||
* Assume a cc65 style four-byte header with start address in bytes 0-1.
|
* Assume a cc65 style four-byte header with start address in bytes 0-1.
|
||||||
*/
|
*/
|
||||||
static void putCC65(String imageName, Name name, String fileType)
|
static void putCC65(String imageName, Name name, String fileType)
|
||||||
throws IOException, DiskFullException {
|
throws IOException, DiskException {
|
||||||
|
|
||||||
byte[] header = new byte[4];
|
byte[] header = new byte[4];
|
||||||
if (System.in.read(header, 0, 4) == 4) {
|
if (System.in.read(header, 0, 4) == 4) {
|
||||||
|
@ -253,7 +256,7 @@ public class ac {
|
||||||
* This would only make sense for a ProDOS-formatted disk.
|
* This would only make sense for a ProDOS-formatted disk.
|
||||||
*/
|
*/
|
||||||
static void putGEOS(String imageName)
|
static void putGEOS(String imageName)
|
||||||
throws IOException, DiskFullException {
|
throws IOException, DiskException {
|
||||||
putFile(imageName, new Name("GEOS-Should Be ProDOS"), "GEO", "0"); //$NON-NLS-2$ $NON-NLS-3$
|
putFile(imageName, new Name("GEOS-Should Be ProDOS"), "GEO", "0"); //$NON-NLS-2$ $NON-NLS-3$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,9 +330,11 @@ public class ac {
|
||||||
directory = "."+File.separator;
|
directory = "."+File.separator;
|
||||||
}
|
}
|
||||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||||
for (int i = 0; i < formattedDisks.length; i++) {
|
for (int i = 0; i < formattedDisks.length; i++) try {
|
||||||
FormattedDisk formattedDisk = formattedDisks[i];
|
FormattedDisk formattedDisk = formattedDisks[i];
|
||||||
writeFiles(formattedDisk.getFiles(), directory);
|
writeFiles(formattedDisk.getFiles(), directory);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME How to warn user about the problem?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,8 +357,10 @@ public class ac {
|
||||||
OutputStream output = new FileOutputStream(file);
|
OutputStream output = new FileOutputStream(file);
|
||||||
output.write(buf, 0, buf.length);
|
output.write(buf, 0, buf.length);
|
||||||
output.close();
|
output.close();
|
||||||
} else if (entry.isDirectory()) {
|
} else if (entry.isDirectory()) try {
|
||||||
writeFiles(((DirectoryEntry) entry).getFiles(),directory+entry.getFilename()+File.separator);
|
writeFiles(((DirectoryEntry) entry).getFiles(),directory+entry.getFilename()+File.separator);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME How to warn user about the problem?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,11 +380,13 @@ public class ac {
|
||||||
if (!entry.isDeleted() && fileName.equalsIgnoreCase(entryName)) {
|
if (!entry.isDeleted() && fileName.equalsIgnoreCase(entryName)) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) try {
|
||||||
entry = getEntry(((DirectoryEntry) entry).getFiles(), fileName);
|
entry = getEntry(((DirectoryEntry) entry).getFiles(), fileName);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME How to warn user about the problem?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,6 +415,8 @@ public class ac {
|
||||||
new Integer(formattedDisk.getUsedSpace()) }));
|
new Integer(formattedDisk.getUsedSpace()) }));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
} catch (DiskException e) {
|
||||||
|
throw new IOException(e);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
System.out.println(args[d] + ": " + e.getMessage()); //$NON-NLS-1$
|
System.out.println(args[d] + ": " + e.getMessage()); //$NON-NLS-1$
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
@ -430,9 +441,11 @@ public class ac {
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) try {
|
||||||
showFiles(((DirectoryEntry) entry).getFiles(),
|
showFiles(((DirectoryEntry) entry).getFiles(),
|
||||||
indent + " ", display); //$NON-NLS-1$
|
indent + " ", display); //$NON-NLS-1$
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME How to warn user about the problem?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,29 +615,33 @@ public class ac {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEntry getEntry(FormattedDisk formattedDisk) {
|
public FileEntry getEntry(FormattedDisk formattedDisk) {
|
||||||
List files = formattedDisk.getFiles();
|
try {
|
||||||
FileEntry entry = null;
|
List files = formattedDisk.getFiles();
|
||||||
for (int i = 0; i < path.length - 1; i++) {
|
FileEntry entry = null;
|
||||||
String dirName = path[i];
|
for (int i = 0; i < path.length - 1; i++) {
|
||||||
for (int j = 0; j < files.size(); j++) {
|
String dirName = path[i];
|
||||||
entry = (FileEntry) files.get(j);
|
for (int j = 0; j < files.size(); j++) {
|
||||||
String entryName = entry.getFilename();
|
entry = (FileEntry) files.get(j);
|
||||||
if (entry.isDirectory() && dirName.equalsIgnoreCase(entryName)) {
|
String entryName = entry.getFilename();
|
||||||
files = ((DirectoryEntry) entry).getFiles();
|
if (entry.isDirectory() && dirName.equalsIgnoreCase(entryName)) {
|
||||||
|
files = ((DirectoryEntry) entry).getFiles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (int i = 0; i < files.size(); i++) {
|
||||||
for (int i = 0; i < files.size(); i++) {
|
entry = (FileEntry) files.get(i);
|
||||||
entry = (FileEntry) files.get(i);
|
String entryName = entry.getFilename();
|
||||||
String entryName = entry.getFilename();
|
if (!entry.isDeleted() && name.equalsIgnoreCase(entryName)) {
|
||||||
if (!entry.isDeleted() && name.equalsIgnoreCase(entryName)) {
|
return entry;
|
||||||
return entry;
|
}
|
||||||
}
|
}
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME How to warn user about the problem?
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEntry createEntry(FormattedDisk formattedDisk) throws DiskFullException {
|
public FileEntry createEntry(FormattedDisk formattedDisk) throws DiskException {
|
||||||
if (path.length == 1) {
|
if (path.length == 1) {
|
||||||
return formattedDisk.createFile();
|
return formattedDisk.createFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -71,6 +72,7 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||||
import com.webcodepro.applecommander.compiler.ApplesoftCompiler;
|
import com.webcodepro.applecommander.compiler.ApplesoftCompiler;
|
||||||
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
import com.webcodepro.applecommander.storage.DirectoryEntry;
|
||||||
import com.webcodepro.applecommander.storage.Disk;
|
import com.webcodepro.applecommander.storage.Disk;
|
||||||
|
import com.webcodepro.applecommander.storage.DiskException;
|
||||||
import com.webcodepro.applecommander.storage.FileEntry;
|
import com.webcodepro.applecommander.storage.FileEntry;
|
||||||
import com.webcodepro.applecommander.storage.FileEntryComparator;
|
import com.webcodepro.applecommander.storage.FileEntryComparator;
|
||||||
import com.webcodepro.applecommander.storage.FileFilter;
|
import com.webcodepro.applecommander.storage.FileFilter;
|
||||||
|
@ -114,6 +116,9 @@ import com.webcodepro.applecommander.util.TextBundle;
|
||||||
* <p>
|
* <p>
|
||||||
* Date created: Nov 17, 2002 9:46:53 PM
|
* Date created: Nov 17, 2002 9:46:53 PM
|
||||||
* @author Rob Greene
|
* @author Rob Greene
|
||||||
|
*
|
||||||
|
* Changed at: Dec 1, 2017
|
||||||
|
* @author Lisias Toledo
|
||||||
*/
|
*/
|
||||||
public class DiskExplorerTab {
|
public class DiskExplorerTab {
|
||||||
private static final char CTRL_C = 'C' - '@';
|
private static final char CTRL_C = 'C' - '@';
|
||||||
|
@ -224,7 +229,11 @@ public class DiskExplorerTab {
|
||||||
* Single-click handler.
|
* Single-click handler.
|
||||||
*/
|
*/
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
changeCurrentFormat(getCurrentFormat()); // minor hack
|
try {
|
||||||
|
changeCurrentFormat(getCurrentFormat()); // minor hack
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Double-click handler.
|
* Double-click handler.
|
||||||
|
@ -248,8 +257,8 @@ public class DiskExplorerTab {
|
||||||
diskItem.setText(disks[i].getDiskName());
|
diskItem.setText(disks[i].getDiskName());
|
||||||
diskItem.setData(disks[i]);
|
diskItem.setData(disks[i]);
|
||||||
directoryTree.setSelection(new TreeItem[] { diskItem });
|
directoryTree.setSelection(new TreeItem[] { diskItem });
|
||||||
|
|
||||||
if (disks[i].canHaveDirectories()) {
|
if (disks[i].canHaveDirectories()) try {
|
||||||
Iterator files = disks[i].getFiles().iterator();
|
Iterator files = disks[i].getFiles().iterator();
|
||||||
while (files.hasNext()) {
|
while (files.hasNext()) {
|
||||||
FileEntry entry = (FileEntry) files.next();
|
FileEntry entry = (FileEntry) files.next();
|
||||||
|
@ -260,15 +269,21 @@ public class DiskExplorerTab {
|
||||||
addDirectoriesToTree(item, (DirectoryEntry)entry);
|
addDirectoriesToTree(item, (DirectoryEntry)entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
computeColumnWidths(FormattedDisk.FILE_DISPLAY_STANDARD);
|
computeColumnWidths(FormattedDisk.FILE_DISPLAY_STANDARD);
|
||||||
computeColumnWidths(FormattedDisk.FILE_DISPLAY_NATIVE);
|
computeColumnWidths(FormattedDisk.FILE_DISPLAY_NATIVE);
|
||||||
computeColumnWidths(FormattedDisk.FILE_DISPLAY_DETAIL);
|
computeColumnWidths(FormattedDisk.FILE_DISPLAY_DETAIL);
|
||||||
|
|
||||||
formatChanged = true;
|
formatChanged = true;
|
||||||
fillFileTable(disks[0].getFiles());
|
try {
|
||||||
|
fillFileTable(disks[0].getFiles());
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
directoryTree.setSelection(new TreeItem[] { directoryTree.getItems()[0] });
|
directoryTree.setSelection(new TreeItem[] { directoryTree.getItems()[0] });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -338,11 +353,15 @@ public class DiskExplorerTab {
|
||||||
item.setImage(imageManager.get(ImageManager.ICON_IMPORT_FILE));
|
item.setImage(imageManager.get(ImageManager.ICON_IMPORT_FILE));
|
||||||
item.addSelectionListener(new SelectionAdapter() {
|
item.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
importFiles();
|
try {
|
||||||
|
importFiles();
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.setEnabled(disks[0].canCreateFile() && disks[0].canWriteFileData());
|
item.setEnabled(disks[0].canCreateFile() && disks[0].canWriteFileData());
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -389,7 +408,11 @@ public class DiskExplorerTab {
|
||||||
item.setImage(imageManager.get(ImageManager.ICON_VIEW_FILE));
|
item.setImage(imageManager.get(ImageManager.ICON_VIEW_FILE));
|
||||||
item.addSelectionListener(new SelectionAdapter() {
|
item.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
viewFile(null);
|
try {
|
||||||
|
viewFile(null);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -444,7 +467,11 @@ public class DiskExplorerTab {
|
||||||
item.setText(textBundle.get("ViewAsTextMenuItem")); //$NON-NLS-1$
|
item.setText(textBundle.get("ViewAsTextMenuItem")); //$NON-NLS-1$
|
||||||
item.addSelectionListener(new SelectionAdapter() {
|
item.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
viewFile(TextFileFilter.class);
|
try {
|
||||||
|
viewFile(TextFileFilter.class);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -452,7 +479,11 @@ public class DiskExplorerTab {
|
||||||
item.setText(textBundle.get("VeiwAsGraphicsMenuItem")); //$NON-NLS-1$
|
item.setText(textBundle.get("VeiwAsGraphicsMenuItem")); //$NON-NLS-1$
|
||||||
item.addSelectionListener(new SelectionAdapter() {
|
item.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
viewFile(GraphicsFileFilter.class);
|
try {
|
||||||
|
viewFile(GraphicsFileFilter.class);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -879,7 +910,11 @@ public class DiskExplorerTab {
|
||||||
* Double-click handler.
|
* Double-click handler.
|
||||||
*/
|
*/
|
||||||
public void widgetDefaultSelected(SelectionEvent event) {
|
public void widgetDefaultSelected(SelectionEvent event) {
|
||||||
viewFile(null);
|
try {
|
||||||
|
viewFile(null);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TableColumn column = null;
|
TableColumn column = null;
|
||||||
|
@ -1101,12 +1136,13 @@ public class DiskExplorerTab {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Start the import wizard and import the selected files.
|
* Start the import wizard and import the selected files.
|
||||||
|
* @throws DiskException
|
||||||
*/
|
*/
|
||||||
protected void importFiles() {
|
protected void importFiles() throws DiskException {
|
||||||
//FIXME: This code has become really ugly!
|
//FIXME: This code has become really ugly!
|
||||||
TreeItem treeItem = directoryTree.getSelection()[0];
|
TreeItem treeItem = directoryTree.getSelection()[0];
|
||||||
DirectoryEntry directory = (DirectoryEntry) treeItem.getData();
|
DirectoryEntry directory = (DirectoryEntry) treeItem.getData();
|
||||||
ImportWizard wizard = new ImportWizard(shell,
|
ImportWizard wizard = new ImportWizard(shell,
|
||||||
imageManager, directory.getFormattedDisk());
|
imageManager, directory.getFormattedDisk());
|
||||||
wizard.open();
|
wizard.open();
|
||||||
if (wizard.isWizardCompleted()) {
|
if (wizard.isWizardCompleted()) {
|
||||||
|
@ -1201,8 +1237,9 @@ public class DiskExplorerTab {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Helper function for building fileTree.
|
* Helper function for building fileTree.
|
||||||
|
* @throws DiskException
|
||||||
*/
|
*/
|
||||||
protected void addDirectoriesToTree(TreeItem directoryItem, DirectoryEntry directoryEntry) {
|
protected void addDirectoriesToTree(TreeItem directoryItem, DirectoryEntry directoryEntry) throws DiskException {
|
||||||
Iterator files = directoryEntry.getFiles().iterator();
|
Iterator files = directoryEntry.getFiles().iterator();
|
||||||
while (files.hasNext()) {
|
while (files.hasNext()) {
|
||||||
final FileEntry entry = (FileEntry) files.next();
|
final FileEntry entry = (FileEntry) files.next();
|
||||||
|
@ -1228,8 +1265,12 @@ public class DiskExplorerTab {
|
||||||
standardFormatToolItem.setToolTipText(textBundle.get("StandardViewHoverText")); //$NON-NLS-1$
|
standardFormatToolItem.setToolTipText(textBundle.get("StandardViewHoverText")); //$NON-NLS-1$
|
||||||
standardFormatToolItem.setSelection(true);
|
standardFormatToolItem.setSelection(true);
|
||||||
standardFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
standardFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD);
|
try {
|
||||||
|
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nativeFormatToolItem = new ToolItem(toolBar, SWT.RADIO);
|
nativeFormatToolItem = new ToolItem(toolBar, SWT.RADIO);
|
||||||
|
@ -1237,8 +1278,12 @@ public class DiskExplorerTab {
|
||||||
nativeFormatToolItem.setText(textBundle.get("NativeViewToolItem")); //$NON-NLS-1$
|
nativeFormatToolItem.setText(textBundle.get("NativeViewToolItem")); //$NON-NLS-1$
|
||||||
nativeFormatToolItem.setToolTipText(textBundle.get("NativeViewHoverText")); //$NON-NLS-1$
|
nativeFormatToolItem.setToolTipText(textBundle.get("NativeViewHoverText")); //$NON-NLS-1$
|
||||||
nativeFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
nativeFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_NATIVE);
|
try {
|
||||||
|
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_NATIVE);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
detailFormatToolItem = new ToolItem(toolBar, SWT.RADIO);
|
detailFormatToolItem = new ToolItem(toolBar, SWT.RADIO);
|
||||||
|
@ -1246,13 +1291,17 @@ public class DiskExplorerTab {
|
||||||
detailFormatToolItem.setText(textBundle.get("DetailViewToolItem")); //$NON-NLS-1$
|
detailFormatToolItem.setText(textBundle.get("DetailViewToolItem")); //$NON-NLS-1$
|
||||||
detailFormatToolItem.setToolTipText(textBundle.get("DetailViewHoverText")); //$NON-NLS-1$
|
detailFormatToolItem.setToolTipText(textBundle.get("DetailViewHoverText")); //$NON-NLS-1$
|
||||||
detailFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
detailFormatToolItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_DETAIL);
|
try {
|
||||||
|
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_DETAIL);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new ToolItem(toolBar, SWT.SEPARATOR);
|
new ToolItem(toolBar, SWT.SEPARATOR);
|
||||||
|
|
||||||
showDeletedFilesToolItem = new ToolItem(toolBar, SWT.CHECK);
|
showDeletedFilesToolItem = new ToolItem(toolBar, SWT.CHECK);
|
||||||
showDeletedFilesToolItem.setImage(imageManager.get(ImageManager.ICON_SHOW_DELETED_FILES));
|
showDeletedFilesToolItem.setImage(imageManager.get(ImageManager.ICON_SHOW_DELETED_FILES));
|
||||||
showDeletedFilesToolItem.setText(textBundle.get("ShowDeletedFilesToolItem")); //$NON-NLS-1$
|
showDeletedFilesToolItem.setText(textBundle.get("ShowDeletedFilesToolItem")); //$NON-NLS-1$
|
||||||
|
@ -1274,11 +1323,15 @@ public class DiskExplorerTab {
|
||||||
importToolItem.setToolTipText(textBundle.get("ImportWizardHoverText")); //$NON-NLS-1$
|
importToolItem.setToolTipText(textBundle.get("ImportWizardHoverText")); //$NON-NLS-1$
|
||||||
importToolItem.setEnabled(disks[0].canCreateFile() && disks[0].canWriteFileData());
|
importToolItem.setEnabled(disks[0].canCreateFile() && disks[0].canWriteFileData());
|
||||||
importToolItem.addSelectionListener(new SelectionAdapter () {
|
importToolItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
importFiles();
|
try {
|
||||||
|
importFiles();
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
exportToolItem = new ToolItem(toolBar, SWT.DROP_DOWN);
|
exportToolItem = new ToolItem(toolBar, SWT.DROP_DOWN);
|
||||||
exportToolItem.setImage(imageManager.get(ImageManager.ICON_EXPORT_FILE));
|
exportToolItem.setImage(imageManager.get(ImageManager.ICON_EXPORT_FILE));
|
||||||
exportToolItem.setText(textBundle.get("ExportWizardToolItem")); //$NON-NLS-1$
|
exportToolItem.setText(textBundle.get("ExportWizardToolItem")); //$NON-NLS-1$
|
||||||
|
@ -1315,9 +1368,11 @@ public class DiskExplorerTab {
|
||||||
viewFileItem.setEnabled(false);
|
viewFileItem.setEnabled(false);
|
||||||
viewFileItem.addSelectionListener(new SelectionAdapter () {
|
viewFileItem.addSelectionListener(new SelectionAdapter () {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
if (event.detail != SWT.ARROW) {
|
if (event.detail != SWT.ARROW) try {
|
||||||
viewFile(null);
|
viewFile(null);
|
||||||
}
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
printToolItem = new ToolItem(toolBar, SWT.PUSH);
|
printToolItem = new ToolItem(toolBar, SWT.PUSH);
|
||||||
|
@ -1402,8 +1457,9 @@ public class DiskExplorerTab {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Change the current format and refresh the display.
|
* Change the current format and refresh the display.
|
||||||
|
* @throws DiskException
|
||||||
*/
|
*/
|
||||||
protected void changeCurrentFormat(int newFormat) {
|
protected void changeCurrentFormat(int newFormat) throws DiskException {
|
||||||
TreeItem selection = directoryTree.getSelection()[0];
|
TreeItem selection = directoryTree.getSelection()[0];
|
||||||
Object data = selection.getData();
|
Object data = selection.getData();
|
||||||
DirectoryEntry directory = (DirectoryEntry) data;
|
DirectoryEntry directory = (DirectoryEntry) data;
|
||||||
|
@ -1522,8 +1578,9 @@ public class DiskExplorerTab {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Open up the view file window for the currently selected file.
|
* Open up the view file window for the currently selected file.
|
||||||
|
* @throws DiskException
|
||||||
*/
|
*/
|
||||||
protected void viewFile(Class fileFilterClass) {
|
protected void viewFile(Class fileFilterClass) throws DiskException {
|
||||||
FileEntry fileEntry = getSelectedFileEntry();
|
FileEntry fileEntry = getSelectedFileEntry();
|
||||||
if (fileEntry.isDeleted()) {
|
if (fileEntry.isDeleted()) {
|
||||||
SwtUtil.showErrorDialog(shell, textBundle.get("DeleteFileErrorTitle"), //$NON-NLS-1$
|
SwtUtil.showErrorDialog(shell, textBundle.get("DeleteFileErrorTitle"), //$NON-NLS-1$
|
||||||
|
@ -1583,8 +1640,8 @@ public class DiskExplorerTab {
|
||||||
return new Listener() {
|
return new Listener() {
|
||||||
public void handleEvent(Event event) {
|
public void handleEvent(Event event) {
|
||||||
FileEntry fileEntry = getSelectedFileEntry();
|
FileEntry fileEntry = getSelectedFileEntry();
|
||||||
if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) {
|
if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0)
|
||||||
switch (event.character) {
|
try { switch (event.character) {
|
||||||
case CTRL_C: // Compile Wizard
|
case CTRL_C: // Compile Wizard
|
||||||
if (getCompileToolItem().isEnabled()) {
|
if (getCompileToolItem().isEnabled()) {
|
||||||
compileFileWizard();
|
compileFileWizard();
|
||||||
|
@ -1601,8 +1658,9 @@ public class DiskExplorerTab {
|
||||||
case CTRL_V: // View file
|
case CTRL_V: // View file
|
||||||
viewFile(null);
|
viewFile(null);
|
||||||
break;
|
break;
|
||||||
}
|
} } catch (DiskException e) {
|
||||||
}
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1624,7 +1682,7 @@ public class DiskExplorerTab {
|
||||||
saveAs();
|
saveAs();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else try {
|
||||||
switch (event.character) {
|
switch (event.character) {
|
||||||
case CTRL_I: // Import Wizard
|
case CTRL_I: // Import Wizard
|
||||||
importFiles();
|
importFiles();
|
||||||
|
@ -1638,10 +1696,12 @@ public class DiskExplorerTab {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
} else { // No CTRL key
|
} else { // No CTRL key
|
||||||
if ((event.stateMask & SWT.ALT) != SWT.ALT) { // Ignore ALT key combinations like alt-F4!
|
if ((event.stateMask & SWT.ALT) != SWT.ALT) // Ignore ALT key combinations like alt-F4!
|
||||||
switch (event.keyCode) {
|
try { switch (event.keyCode) {
|
||||||
case SWT.F2: // Standard file display
|
case SWT.F2: // Standard file display
|
||||||
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD);
|
changeCurrentFormat(FormattedDisk.FILE_DISPLAY_STANDARD);
|
||||||
break;
|
break;
|
||||||
|
@ -1657,7 +1717,9 @@ public class DiskExplorerTab {
|
||||||
fillFileTable(getCurrentFileList());
|
fillFileTable(getCurrentFileList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1728,7 +1790,11 @@ public class DiskExplorerTab {
|
||||||
printFileHeaders();
|
printFileHeaders();
|
||||||
gc.setFont(normalFont);
|
gc.setFont(normalFont);
|
||||||
println(disk.getDiskName());
|
println(disk.getDiskName());
|
||||||
printFiles(disk, 1);
|
try {
|
||||||
|
printFiles(disk, 1);
|
||||||
|
} catch (DiskException e) {
|
||||||
|
// FIXME how to warn the User about this?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (y != clientArea.y) { // partial page
|
if (y != clientArea.y) { // partial page
|
||||||
printFooter();
|
printFooter();
|
||||||
|
@ -1811,7 +1877,7 @@ public class DiskExplorerTab {
|
||||||
clientArea.y + clientArea.height + dpiY - point.y);
|
clientArea.y + clientArea.height + dpiY - point.y);
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
protected void printFiles(DirectoryEntry directory, int level) {
|
protected void printFiles(DirectoryEntry directory, int level) throws DiskException {
|
||||||
Iterator iterator = directory.getFiles().iterator();
|
Iterator iterator = directory.getFiles().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
FileEntry fileEntry = (FileEntry) iterator.next();
|
FileEntry fileEntry = (FileEntry) iterator.next();
|
||||||
|
|
Loading…
Reference in New Issue