Compare commits

...

6 Commits

19 changed files with 304 additions and 199 deletions

View File

@ -19,16 +19,14 @@
*/ */
package io.github.applecommander.acx.command; package io.github.applecommander.acx.command;
import java.util.List; import com.webcodepro.applecommander.storage.DirectoryEntry;
import java.util.logging.Logger; import com.webcodepro.applecommander.storage.Disk;
import java.util.stream.Collectors; import com.webcodepro.applecommander.storage.DiskException;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.*;
import com.webcodepro.applecommander.util.Name; import com.webcodepro.applecommander.util.Name;
import com.webcodepro.applecommander.util.filestreamer.FileStreamer; import com.webcodepro.applecommander.util.filestreamer.FileStreamer;
import com.webcodepro.applecommander.util.filestreamer.FileTuple; import com.webcodepro.applecommander.util.filestreamer.FileTuple;
import com.webcodepro.applecommander.util.filestreamer.TypeOfFile; import com.webcodepro.applecommander.util.filestreamer.TypeOfFile;
import io.github.applecommander.acx.base.ReadWriteDiskCommandOptions; import io.github.applecommander.acx.base.ReadWriteDiskCommandOptions;
import io.github.applecommander.acx.converter.DiskConverter; import io.github.applecommander.acx.converter.DiskConverter;
import io.github.applecommander.acx.fileutil.FileUtils; import io.github.applecommander.acx.fileutil.FileUtils;
@ -36,6 +34,10 @@ import picocli.CommandLine.Command;
import picocli.CommandLine.Option; import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters; import picocli.CommandLine.Parameters;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@Command(name = "copy", description = "Copy files between disks.", @Command(name = "copy", description = "Copy files between disks.",
aliases = { "cp" }) aliases = { "cp" })
public class CopyFileCommand extends ReadWriteDiskCommandOptions { public class CopyFileCommand extends ReadWriteDiskCommandOptions {
@ -63,7 +65,7 @@ public class CopyFileCommand extends ReadWriteDiskCommandOptions {
List<FileTuple> files = FileStreamer.forDisk(sourceDisk) List<FileTuple> files = FileStreamer.forDisk(sourceDisk)
.ignoreErrors(true) .ignoreErrors(true)
.includeTypeOfFile(TypeOfFile.BOTH) .includeTypeOfFile(TypeOfFile.BOTH)
.recursive(recursiveFlag) .recursive(false) // we handle recursion in the FileUtils
.matchGlobs(globs) .matchGlobs(globs)
.stream() .stream()
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -19,17 +19,16 @@
*/ */
package io.github.applecommander.acx.fileutil; package io.github.applecommander.acx.fileutil;
import java.util.Optional;
import java.util.logging.Logger;
import com.webcodepro.applecommander.storage.DirectoryEntry; import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskException; import com.webcodepro.applecommander.storage.DiskException;
import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.util.readerwriter.FileEntryReader; import com.webcodepro.applecommander.util.readerwriter.FileEntryReader;
import com.webcodepro.applecommander.util.readerwriter.FileEntryWriter; import com.webcodepro.applecommander.util.readerwriter.FileEntryWriter;
import io.github.applecommander.acx.command.CopyFileCommand; import io.github.applecommander.acx.command.CopyFileCommand;
import java.util.Optional;
import java.util.logging.Logger;
public class FileUtils { public class FileUtils {
private static Logger LOG = Logger.getLogger(CopyFileCommand.class.getName()); private static Logger LOG = Logger.getLogger(CopyFileCommand.class.getName());
@ -40,7 +39,7 @@ public class FileUtils {
} }
public void copy(DirectoryEntry directory, FileEntry file) throws DiskException { public void copy(DirectoryEntry directory, FileEntry file) throws DiskException {
LOG.fine(() -> String.format("Copying '%s'", file.getFilename())); LOG.fine(() -> String.format("Copying '%s' into directory '%s'", file.getFilename(), directory.getDirname()));
if (file.isDeleted()) { if (file.isDeleted()) {
// Skip deleted files // Skip deleted files
} }
@ -112,13 +111,15 @@ public class FileUtils {
source.getBinaryAddress().ifPresent(target::setBinaryAddress); source.getBinaryAddress().ifPresent(target::setBinaryAddress);
source.getBinaryLength().ifPresent(target::setBinaryLength); source.getBinaryLength().ifPresent(target::setBinaryLength);
source.getAuxiliaryType().ifPresent(target::setAuxiliaryType); source.getAuxiliaryType().ifPresent(target::setAuxiliaryType);
source.getCreationDate().ifPresent(target::setCreationDate); source.getCreationDate().ifPresent(target::setCreationDate);
source.getLastModificationDate().ifPresent(target::setLastModificationDate);
if (source.getFileData().isPresent() && source.getResourceData().isPresent()) { if (source.getFileData().isPresent() && source.getResourceData().isPresent()) {
target.setFileData(source.getFileData().get(), source.getResourceData().get()); target.setFileData(source.getFileData().get(), source.getResourceData().get());
} else { } else {
source.getFileData().ifPresent(target::setFileData); source.getFileData().ifPresent(target::setFileData);
} }
// Modification date needs to be done last since writing file data/attributes are likely to change it
source.getLastModificationDate().ifPresent(target::setLastModificationDate);
} }
} }

View File

@ -9,11 +9,11 @@ asVersion=1.2.1
btVersion=0.3.1 btVersion=0.3.1
swtVersion=3.123.0 swtVersion=3.123.0
piSwtVersion=3.8.2 piSwtVersion=3.8.2
junitVersion=4.12 junitVersion=4.13.1
antVersion=1.8.2 antVersion=1.9.16
commonsLang3Version=3.7 commonsLang3Version=3.7
commonsCsvVersion=1.8 commonsCsvVersion=1.8
gsonVersion=2.8.6 gsonVersion=2.8.9
picocliVersion=4.6.2 picocliVersion=4.6.2
springBoot=2.6.1 springBoot=2.6.1
acdasmVersion=0.4.0 acdasmVersion=0.4.0

View File

@ -33,6 +33,11 @@ import java.util.List;
* @author Lisias Toledo * @author Lisias Toledo
*/ */
public interface DirectoryEntry { public interface DirectoryEntry {
/**
* Return a name for this directory.
*/
public String getDirname();
/** /**
* Retrieve the list of files in this directory. * Retrieve the list of files in this directory.
* Note that if this is not a directory, the return * Note that if this is not a directory, the return

View File

@ -19,14 +19,15 @@
*/ */
package com.webcodepro.applecommander.storage; package com.webcodepro.applecommander.storage;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.TextBundle;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.TextBundle;
/** /**
* Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk). * Abstract representation of a formatted Apple2 disk (floppy, 800k, hard disk).
@ -139,7 +140,14 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS). * but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS).
*/ */
public abstract String getDiskName(); public abstract String getDiskName();
/**
* Return a name for this directory.
*/
public String getDirname(){
return getDiskName();
}
/** /**
* Set the name of the disk to volumeName. * Set the name of the disk to volumeName.
*/ */
@ -404,4 +412,15 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* Gives an indication on how this disk's geometry should be handled. * Gives an indication on how this disk's geometry should be handled.
*/ */
public abstract DiskGeometry getDiskGeometry(); public abstract DiskGeometry getDiskGeometry();
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
public abstract String fromProdosFiletype(String prodosFiletype);
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
public abstract String toProdosFiletype(String nativeFiletype);
} }

View File

@ -19,22 +19,13 @@
*/ */
package com.webcodepro.applecommander.storage.os.cpm; package com.webcodepro.applecommander.storage.os.cpm;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/** /**
* Manages a disk that is in the Apple CP/M format. * Manages a disk that is in the Apple CP/M format.
* <p> * <p>
@ -565,4 +556,29 @@ public class CpmFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.TRACK_SECTOR; return DiskGeometry.TRACK_SECTOR;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
if ("TXT".equalsIgnoreCase(prodosFiletype)) {
return "TXT";
}
return "BIN";
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
for (String textFiletype : CpmFileEntry.TEXT_FILETYPES) {
if (textFiletype.equalsIgnoreCase(nativeFiletype)) {
return "TXT";
}
}
return "BIN";
}
} }

View File

@ -19,23 +19,13 @@
*/ */
package com.webcodepro.applecommander.storage.os.dos33; package com.webcodepro.applecommander.storage.os.dos33;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
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.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/** /**
* Manages a disk that is in Apple DOS 3.3 format. * Manages a disk that is in Apple DOS 3.3 format.
* <p> * <p>
@ -70,11 +60,20 @@ public class DosFormatDisk extends FormattedDisk {
/** /**
* The list of filetypes available. * The list of filetypes available.
*/ */
private static final String[] filetypes = { private static final String[] FILE_TYPES = {
"T", "A", "I", "B", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "T", "A", "I", "B",
"S", "R", "a", "b" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "S", "R", "a", "b"
}; };
private static final Map<String,String> FILE_TYPE_MAPPING = Map.of(
"T", "TXT",
"I", "INT",
"A", "BAS",
"B", "BIN",
"S", "$F1",
"R", "REL",
"a", "$F2",
"b", "$F3"
);
/** /**
* Use this inner interface for managing the disk usage data. * Use this inner interface for managing the disk usage data.
* This off-loads format-specific implementation to the implementing class. * This off-loads format-specific implementation to the implementing class.
@ -739,7 +738,7 @@ public class DosFormatDisk extends FormattedDisk {
* specific to each operating system, a simple String is used. * specific to each operating system, a simple String is used.
*/ */
public String[] getFiletypes() { public String[] getFiletypes() {
return filetypes; return FILE_TYPES;
} }
/** /**
@ -781,4 +780,26 @@ public class DosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.TRACK_SECTOR; return DiskGeometry.TRACK_SECTOR;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return FILE_TYPE_MAPPING.entrySet()
.stream()
.filter(e -> e.getValue().equals(prodosFiletype))
.map(Map.Entry::getKey)
.findFirst()
.orElse("B");
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return FILE_TYPE_MAPPING.getOrDefault(nativeFiletype, "BIN");
}
} }

View File

@ -19,19 +19,14 @@
*/ */
package com.webcodepro.applecommander.storage.os.gutenberg; package com.webcodepro.applecommander.storage.os.gutenberg;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.ArrayList;
import java.util.List;
/** /**
* Manages a disk that is in Gutenberg Word Processor format. * Manages a disk that is in Gutenberg Word Processor format.
* <p> * <p>
@ -707,4 +702,21 @@ public class GutenbergFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.TRACK_SECTOR; return DiskGeometry.TRACK_SECTOR;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return "T";
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return "TXT";
}
} }

View File

@ -19,19 +19,14 @@
*/ */
package com.webcodepro.applecommander.storage.os.nakedos; package com.webcodepro.applecommander.storage.os.nakedos;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.ArrayList;
import java.util.List;
/** /**
* Manages a disk that is in NakedOS format. * Manages a disk that is in NakedOS format.
* <p> * <p>
@ -545,4 +540,21 @@ public class NakedosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.TRACK_SECTOR; return DiskGeometry.TRACK_SECTOR;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return "B";
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return "BIN";
}
} }

View File

@ -21,21 +21,13 @@
*/ */
package com.webcodepro.applecommander.storage.os.pascal; package com.webcodepro.applecommander.storage.os.pascal;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.BitSet;
import java.util.Date;
import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/** /**
* Manages a disk that is in the Pascal format. * Manages a disk that is in the Pascal format.
* <p> * <p>
@ -58,15 +50,31 @@ public class PascalFormatDisk extends FormattedDisk {
/** /**
* The known filetypes for a Pascal disk. * The known filetypes for a Pascal disk.
*/ */
private static final String[] filetypes = { private static final String[] FILE_TYPES = {
"xdskfile", //$NON-NLS-1$ "xdskfile",
CODEFILE, CODEFILE,
TEXTFILE, TEXTFILE,
"INFO", //$NON-NLS-1$ "INFO",
DATAFILE, DATAFILE,
"GRAF", //$NON-NLS-1$ "GRAF",
"FOTO", //$NON-NLS-1$ "FOTO",
"securedir" }; //$NON-NLS-1$ "securedir"
};
private static final Map<String,String> FILE_TYPE_MAP = Map.of(
// Pascal => Prodos
"xdskfile", "BAD",
CODEFILE, "BIN",
TEXTFILE, "TXT",
"INFO", "TXT",
DATAFILE, "BIN",
"GRAF", "BIN",
"FOTO", "BIN",
"securedir", "BIN",
// Prodos => Pascal
"BIN", DATAFILE,
"TXT", TEXTFILE
);
/** /**
* Use this inner interface for managing the disk usage data. * Use this inner interface for managing the disk usage data.
@ -624,7 +632,7 @@ public class PascalFormatDisk extends FormattedDisk {
* specific to each operating system, a simple String is used. * specific to each operating system, a simple String is used.
*/ */
public String[] getFiletypes() { public String[] getFiletypes() {
return filetypes; return FILE_TYPES;
} }
/** /**
@ -675,4 +683,21 @@ public class PascalFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.BLOCK; return DiskGeometry.BLOCK;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return FILE_TYPE_MAP.getOrDefault(prodosFiletype, DATAFILE);
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return FILE_TYPE_MAP.getOrDefault(nativeFiletype, "BIN");
}
} }

View File

@ -19,13 +19,13 @@
*/ */
package com.webcodepro.applecommander.storage.os.prodos; package com.webcodepro.applecommander.storage.os.prodos;
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.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 java.util.List;
/** /**
* Implement directory functionality. * Implement directory functionality.
* <p> * <p>
@ -55,6 +55,13 @@ public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEn
return this.subdirectoryHeader; return this.subdirectoryHeader;
} }
/**
* Return a name for this directory.
*/
public String getDirname(){
return getFilename();
}
/** /**
* Retrieve the list of files in this directory. * Retrieve the list of files in this directory.
* Note that if this is not a directory, the return * Note that if this is not a directory, the return

View File

@ -19,27 +19,15 @@
*/ */
package com.webcodepro.applecommander.storage.os.prodos; package com.webcodepro.applecommander.storage.os.prodos;
import java.io.IOException; import com.webcodepro.applecommander.storage.*;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
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.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/** /**
* Manages a disk that is in the ProDOS format. * Manages a disk that is in the ProDOS format.
* <p> * <p>
@ -1469,4 +1457,21 @@ public class ProdosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.BLOCK; return DiskGeometry.BLOCK;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return prodosFiletype;
};
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return nativeFiletype;
};
} }

View File

@ -19,21 +19,17 @@
*/ */
package com.webcodepro.applecommander.storage.os.rdos; package com.webcodepro.applecommander.storage.os.rdos;
import java.util.ArrayList; import com.webcodepro.applecommander.storage.*;
import java.util.BitSet;
import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.DiskGeometry;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder; import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder; import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
/** /**
* Manages a disk that is in the RDOS format. * Manages a disk that is in the RDOS format.
* <p> * <p>
@ -79,7 +75,12 @@ public class RdosFormatDisk extends FormattedDisk {
/** /**
* The known filetypes for a RDOS disk. * The known filetypes for a RDOS disk.
*/ */
public static final String[] filetypes = { "B", "A", "T" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ public static final String[] FILE_TYPES = { "B", "A", "T" };
private static final Map<String,String> FILE_TYPE_MAPPING = Map.of(
"T", "TXT",
"A", "BAS",
"B", "BIN"
);
/** /**
* 13 sectors for RDOS 2.1/3.2, native sectoring (16) for RDOS 3.3 * 13 sectors for RDOS 2.1/3.2, native sectoring (16) for RDOS 3.3
@ -517,7 +518,7 @@ public class RdosFormatDisk extends FormattedDisk {
* specific to each operating system, a simple String is used. * specific to each operating system, a simple String is used.
*/ */
public String[] getFiletypes() { public String[] getFiletypes() {
return filetypes; return FILE_TYPES;
} }
/** /**
@ -570,4 +571,26 @@ public class RdosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() { public DiskGeometry getDiskGeometry() {
return DiskGeometry.TRACK_SECTOR; return DiskGeometry.TRACK_SECTOR;
} }
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return FILE_TYPE_MAPPING.entrySet()
.stream()
.filter(e -> e.getValue().equals(prodosFiletype))
.map(Map.Entry::getKey)
.findFirst()
.orElse("B");
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
*/
@Override
public String toProdosFiletype(String nativeFiletype) {
return FILE_TYPE_MAPPING.getOrDefault(nativeFiletype, "BIN");
}
} }

View File

@ -19,29 +19,14 @@
*/ */
package com.webcodepro.applecommander.util.readerwriter; package com.webcodepro.applecommander.util.readerwriter;
import java.util.Map;
import java.util.Optional;
import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.os.dos33.DosFileEntry; import com.webcodepro.applecommander.storage.os.dos33.DosFileEntry;
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk; import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
import com.webcodepro.applecommander.util.AppleUtil; import com.webcodepro.applecommander.util.AppleUtil;
import java.util.Optional;
public class DosFileEntryReaderWriter implements FileEntryReader, FileEntryWriter { public class DosFileEntryReaderWriter implements FileEntryReader, FileEntryWriter {
private static final Map<String,String> FILE_TYPES;
static {
FILE_TYPES = Map.of(
"T", "TXT",
"I", "INT",
"A", "BAS",
"B", "BIN",
"S", "$F1",
"R", "REL",
"a", "$F2",
"b", "$F3"
);
}
private DosFileEntry fileEntry; private DosFileEntry fileEntry;
public DosFileEntryReaderWriter(DosFileEntry fileEntry) { public DosFileEntryReaderWriter(DosFileEntry fileEntry) {
@ -62,17 +47,13 @@ public class DosFileEntryReaderWriter implements FileEntryReader, FileEntryWrite
@Override @Override
public Optional<String> getProdosFiletype() { public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype())); String prodosFiletype = fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype());
return Optional.ofNullable(prodosFiletype);
} }
@Override @Override
public void setProdosFiletype(String filetype) { public void setProdosFiletype(String filetype) {
String dosFileType = FILE_TYPES.entrySet() String dosFiletype = fileEntry.getFormattedDisk().fromProdosFiletype(filetype);
.stream() fileEntry.setFiletype(dosFiletype);
.filter(e -> e.getValue().equals(filetype))
.map(Map.Entry::getKey)
.findFirst()
.orElse("B");
fileEntry.setFiletype(dosFileType);
} }
@Override @Override

View File

@ -19,35 +19,16 @@
*/ */
package com.webcodepro.applecommander.util.readerwriter; package com.webcodepro.applecommander.util.readerwriter;
import java.util.Date;
import java.util.Map;
import java.util.Optional;
import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.filters.PascalTextFileFilter; import com.webcodepro.applecommander.storage.filters.PascalTextFileFilter;
import com.webcodepro.applecommander.storage.os.pascal.PascalFileEntry; import com.webcodepro.applecommander.storage.os.pascal.PascalFileEntry;
import java.util.Date;
import java.util.Optional;
public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWriter { public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWriter {
private static final PascalTextFileFilter TEXT_FILTER = new PascalTextFileFilter(); private static final PascalTextFileFilter TEXT_FILTER = new PascalTextFileFilter();
private static final Map<String,String> FILE_TYPES;
static {
FILE_TYPES = Map.of(
// Pascal => Prodos
"xdskfile", "BAD", // TODO we should skip bad block files
"CODE", "BIN", // TODO is there an address?
"TEXT", "TXT",
"INFO", "TXT", // TODO We should skip debugger info
"DATA", "BIN",
"GRAF", "BIN", // TODO compressed graphics image
"FOTO", "BIN", // TODO screen image
"securedir", "BIN", // TODO is this even implemented
// Prodos => Pascal
"BIN", "DATA",
"TXT", "TEXT"
);
}
private PascalFileEntry fileEntry; private PascalFileEntry fileEntry;
public PascalFileEntryReaderWriter(PascalFileEntry fileEntry) { public PascalFileEntryReaderWriter(PascalFileEntry fileEntry) {
@ -65,11 +46,11 @@ public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWr
@Override @Override
public Optional<String> getProdosFiletype() { public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype())); return Optional.ofNullable(fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype()));
} }
@Override @Override
public void setProdosFiletype(String filetype) { public void setProdosFiletype(String filetype) {
fileEntry.setFiletype(FILE_TYPES.getOrDefault(filetype, "DATA")); fileEntry.setFiletype(fileEntry.getFormattedDisk().fromProdosFiletype(filetype));
} }
@Override @Override

View File

@ -19,21 +19,11 @@
*/ */
package com.webcodepro.applecommander.util.readerwriter; package com.webcodepro.applecommander.util.readerwriter;
import java.util.Map;
import java.util.Optional;
import com.webcodepro.applecommander.storage.os.rdos.RdosFileEntry; import com.webcodepro.applecommander.storage.os.rdos.RdosFileEntry;
import java.util.Optional;
public class RdosFileEntryReader implements FileEntryReader { public class RdosFileEntryReader implements FileEntryReader {
private static final Map<String,String> FILE_TYPES;
static {
FILE_TYPES = Map.of(
"T", "TXT",
"A", "BAS",
"B", "BIN"
);
}
private RdosFileEntry fileEntry; private RdosFileEntry fileEntry;
public RdosFileEntryReader(RdosFileEntry fileEntry) { public RdosFileEntryReader(RdosFileEntry fileEntry) {
@ -52,7 +42,7 @@ public class RdosFileEntryReader implements FileEntryReader {
@Override @Override
public Optional<String> getProdosFiletype() { public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype())); return Optional.ofNullable(fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype()));
} }
@Override @Override

View File

@ -69,6 +69,7 @@ public class DiskWindow {
shell = new Shell(parentShell, SWT.SHELL_TRIM); shell = new Shell(parentShell, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout()); shell.setLayout(new FillLayout());
shell.setImage(imageManager.get(ImageManager.ICON_DISK)); shell.setImage(imageManager.get(ImageManager.ICON_DISK));
shell.setMinimumSize(400, 300);
setStandardWindowTitle(); setStandardWindowTitle();
shell.addDisposeListener(new DisposeListener() { shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) { public void widgetDisposed(DisposeEvent event) {

View File

@ -19,23 +19,6 @@
*/ */
package com.webcodepro.applecommander.ui.swt; package com.webcodepro.applecommander.ui.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.webcodepro.applecommander.storage.Disk; import com.webcodepro.applecommander.storage.Disk;
import com.webcodepro.applecommander.storage.Disk.FilenameFilter; import com.webcodepro.applecommander.storage.Disk.FilenameFilter;
import com.webcodepro.applecommander.storage.DiskUnrecognizedException; import com.webcodepro.applecommander.storage.DiskUnrecognizedException;
@ -49,6 +32,17 @@ import com.webcodepro.applecommander.ui.swt.wizard.comparedisks.CompareDisksWiza
import com.webcodepro.applecommander.ui.swt.wizard.diskimage.DiskImageWizard; import com.webcodepro.applecommander.ui.swt.wizard.diskimage.DiskImageWizard;
import com.webcodepro.applecommander.util.Host; import com.webcodepro.applecommander.util.Host;
import com.webcodepro.applecommander.util.TextBundle; import com.webcodepro.applecommander.util.TextBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
/** /**
* Main class for the SwtAppleCommander interface. * Main class for the SwtAppleCommander interface.
@ -134,6 +128,15 @@ public class SwtAppleCommander implements Listener {
*/ */
protected Shell open(Display display) { protected Shell open(Display display) {
Display.setAppName(textBundle.get("SwtAppleCommander.AppleCommander")); //$NON-NLS-1$ Display.setAppName(textBundle.get("SwtAppleCommander.AppleCommander")); //$NON-NLS-1$
// Find the system About menu on Mac OS X.
// See https://www.eclipse.org/swt/R3_7/new_and_noteworthy.html#m6
if (display.getSystemMenu() != null) {
for (MenuItem item : display.getSystemMenu().getItems()) {
if (item.getID() == SWT.ID_ABOUT) {
item.addSelectionListener(widgetSelectedAdapter(e -> showAboutAppleCommander()));
}
}
}
shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.TITLE); shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.TITLE);
shell.setText(textBundle.get("SwtAppleCommander.AppleCommander")); //$NON-NLS-1$ shell.setText(textBundle.get("SwtAppleCommander.AppleCommander")); //$NON-NLS-1$
shell.setImage(imageManager.get(ImageManager.ICON_DISK)); shell.setImage(imageManager.get(ImageManager.ICON_DISK));

View File

@ -211,7 +211,8 @@ public class ImportSelectFilesWizardPane extends WizardPane {
AppleSingle as = AppleSingle.read(data); AppleSingle as = AppleSingle.read(data);
suggestedFilename = Optional.ofNullable(as.getRealName()) suggestedFilename = Optional.ofNullable(as.getRealName())
.orElse(suggestedFilename); .orElse(suggestedFilename);
suggestedFiletype = ProdosFormatDisk.getFiletype(as.getProdosFileInfo().getFileType()); suggestedFiletype = wizard.getDisk().fromProdosFiletype(
ProdosFormatDisk.getFiletype(as.getProdosFileInfo().getFileType()));
suggestedAddress = Optional.ofNullable(as.getProdosFileInfo()) suggestedAddress = Optional.ofNullable(as.getProdosFileInfo())
.map(ProdosFileInfo::getAuxType) .map(ProdosFileInfo::getAuxType)
.orElse(suggestedAddress); .orElse(suggestedAddress);
@ -285,7 +286,7 @@ public class ImportSelectFilesWizardPane extends WizardPane {
label.setText(textBundle.get("FiletypeLabel")); //$NON-NLS-1$ label.setText(textBundle.get("FiletypeLabel")); //$NON-NLS-1$
final Combo filetypes = new Combo(dialog, SWT.BORDER | SWT.READ_ONLY); final Combo filetypes = new Combo(dialog, SWT.BORDER | SWT.READ_ONLY);
filetypes.setItems(wizard.getDisk().getFiletypes()); filetypes.setItems(wizard.getDisk().getFiletypes());
if (spec.hasFiletype()) { if (spec.hasFiletype() && filetypes.indexOf(spec.getFiletype()) != -1) {
filetypes.select(filetypes.indexOf(spec.getFiletype())); filetypes.select(filetypes.indexOf(spec.getFiletype()));
} }