Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Lass c46bead159
Merge 6fd492e5d0 into 5cd97c6d35 2023-10-27 16:34:42 -07:00
Rob Greene 5cd97c6d35 Fixing recursive acx copy. #130 2023-10-27 16:37:03 -05:00
Rob Greene a375e25c66 Updating FormattedDisk API to support conversion between ProDOS file types and native file types; updated UI to use this API for imports (specifically for AppleSingle archives) in order to set the correct native file type. Fixed glitch in UI where it assumed that the file type was always found in the known list of file types. #128 2023-10-27 14:27:29 -05:00
Rob Greene 1c86c39ed2 Bumping versions identified as vulnerable. 2023-10-27 11:43:43 -05:00
Michael Laß 6fd492e5d0 Update to Gradle 8.1.1
Gradle 8.1 allows building this project with Java 20.

Spring Boot needs to be updated as well to support Gradle 8.1. This
change updates Spring Boot to the latest available version 3.1.0.
2023-06-21 17:02:39 +02:00
22 changed files with 315 additions and 199 deletions

View File

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

View File

@ -19,17 +19,16 @@
*/
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.DiskException;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.util.readerwriter.FileEntryReader;
import com.webcodepro.applecommander.util.readerwriter.FileEntryWriter;
import io.github.applecommander.acx.command.CopyFileCommand;
import java.util.Optional;
import java.util.logging.Logger;
public class FileUtils {
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 {
LOG.fine(() -> String.format("Copying '%s'", file.getFilename()));
LOG.fine(() -> String.format("Copying '%s' into directory '%s'", file.getFilename(), directory.getDirname()));
if (file.isDeleted()) {
// Skip deleted files
}
@ -112,13 +111,15 @@ public class FileUtils {
source.getBinaryAddress().ifPresent(target::setBinaryAddress);
source.getBinaryLength().ifPresent(target::setBinaryLength);
source.getAuxiliaryType().ifPresent(target::setAuxiliaryType);
source.getCreationDate().ifPresent(target::setCreationDate);
source.getLastModificationDate().ifPresent(target::setLastModificationDate);
source.getCreationDate().ifPresent(target::setCreationDate);
if (source.getFileData().isPresent() && source.getResourceData().isPresent()) {
target.setFileData(source.getFileData().get(), source.getResourceData().get());
} else {
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
swtVersion=3.123.0
piSwtVersion=3.8.2
junitVersion=4.12
antVersion=1.8.2
junitVersion=4.13.1
antVersion=1.9.16
commonsLang3Version=3.7
commonsCsvVersion=1.8
gsonVersion=2.8.6
gsonVersion=2.8.9
picocliVersion=4.6.2
springBoot=2.6.1
springBoot=3.1.0
acdasmVersion=0.4.0

Binary file not shown.

View File

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

25
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@ -80,13 +80,10 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View File

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@ -41,12 +41,12 @@ javadoc {
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

View File

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

View File

@ -19,14 +19,15 @@
*/
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.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
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).
@ -139,7 +140,14 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* but "DISK VOLUME #xxx" (DOS 3.3) or "/MY.DISK" (ProDOS).
*/
public abstract String getDiskName();
/**
* Return a name for this directory.
*/
public String getDirname(){
return getDiskName();
}
/**
* 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.
*/
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/**
* Manages a disk that is in the Apple CP/M format.
* <p>
@ -565,4 +556,29 @@ public class CpmFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/**
* Manages a disk that is in Apple DOS 3.3 format.
* <p>
@ -70,11 +60,20 @@ public class DosFormatDisk extends FormattedDisk {
/**
* The list of filetypes available.
*/
private static final String[] filetypes = {
"T", "A", "I", "B", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"S", "R", "a", "b" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
private static final String[] FILE_TYPES = {
"T", "A", "I", "B",
"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.
* 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.
*/
public String[] getFiletypes() {
return filetypes;
return FILE_TYPES;
}
/**
@ -781,4 +780,26 @@ public class DosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
import java.util.ArrayList;
import java.util.List;
/**
* Manages a disk that is in Gutenberg Word Processor format.
* <p>
@ -707,4 +702,21 @@ public class GutenbergFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
import java.util.ArrayList;
import java.util.List;
/**
* Manages a disk that is in NakedOS format.
* <p>
@ -545,4 +540,21 @@ public class NakedosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
import java.util.*;
/**
* Manages a disk that is in the Pascal format.
* <p>
@ -58,15 +50,31 @@ public class PascalFormatDisk extends FormattedDisk {
/**
* The known filetypes for a Pascal disk.
*/
private static final String[] filetypes = {
"xdskfile", //$NON-NLS-1$
private static final String[] FILE_TYPES = {
"xdskfile",
CODEFILE,
TEXTFILE,
"INFO", //$NON-NLS-1$
"INFO",
DATAFILE,
"GRAF", //$NON-NLS-1$
"FOTO", //$NON-NLS-1$
"securedir" }; //$NON-NLS-1$
"GRAF",
"FOTO",
"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.
@ -624,7 +632,7 @@ public class PascalFormatDisk extends FormattedDisk {
* specific to each operating system, a simple String is used.
*/
public String[] getFiletypes() {
return filetypes;
return FILE_TYPES;
}
/**
@ -675,4 +683,21 @@ public class PascalFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskException;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.FileEntry;
import java.util.List;
/**
* Implement directory functionality.
* <p>
@ -55,6 +55,13 @@ public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEn
return this.subdirectoryHeader;
}
/**
* Return a name for this directory.
*/
public String getDirname(){
return getFilename();
}
/**
* Retrieve the list of files in this directory.
* Note that if this is not a directory, the return

View File

@ -19,27 +19,15 @@
*/
package com.webcodepro.applecommander.storage.os.prodos;
import java.io.IOException;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.util.AppleUtil;
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.
* <p>
@ -1469,4 +1457,21 @@ public class ProdosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.ArrayList;
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.*;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import com.webcodepro.applecommander.util.AppleUtil;
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.
* <p>
@ -79,7 +75,12 @@ public class RdosFormatDisk extends FormattedDisk {
/**
* 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
@ -517,7 +518,7 @@ public class RdosFormatDisk extends FormattedDisk {
* specific to each operating system, a simple String is used.
*/
public String[] getFiletypes() {
return filetypes;
return FILE_TYPES;
}
/**
@ -570,4 +571,26 @@ public class RdosFormatDisk extends FormattedDisk {
public DiskGeometry getDiskGeometry() {
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;
import java.util.Map;
import java.util.Optional;
import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.os.dos33.DosFileEntry;
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
import com.webcodepro.applecommander.util.AppleUtil;
import java.util.Optional;
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;
public DosFileEntryReaderWriter(DosFileEntry fileEntry) {
@ -62,17 +47,13 @@ public class DosFileEntryReaderWriter implements FileEntryReader, FileEntryWrite
@Override
public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype()));
String prodosFiletype = fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype());
return Optional.ofNullable(prodosFiletype);
}
@Override
public void setProdosFiletype(String filetype) {
String dosFileType = FILE_TYPES.entrySet()
.stream()
.filter(e -> e.getValue().equals(filetype))
.map(Map.Entry::getKey)
.findFirst()
.orElse("B");
fileEntry.setFiletype(dosFileType);
String dosFiletype = fileEntry.getFormattedDisk().fromProdosFiletype(filetype);
fileEntry.setFiletype(dosFiletype);
}
@Override

View File

@ -19,35 +19,16 @@
*/
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.filters.PascalTextFileFilter;
import com.webcodepro.applecommander.storage.os.pascal.PascalFileEntry;
import java.util.Date;
import java.util.Optional;
public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWriter {
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;
public PascalFileEntryReaderWriter(PascalFileEntry fileEntry) {
@ -65,11 +46,11 @@ public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWr
@Override
public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype()));
return Optional.ofNullable(fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype()));
}
@Override
public void setProdosFiletype(String filetype) {
fileEntry.setFiletype(FILE_TYPES.getOrDefault(filetype, "DATA"));
fileEntry.setFiletype(fileEntry.getFormattedDisk().fromProdosFiletype(filetype));
}
@Override

View File

@ -19,21 +19,11 @@
*/
package com.webcodepro.applecommander.util.readerwriter;
import java.util.Map;
import java.util.Optional;
import com.webcodepro.applecommander.storage.os.rdos.RdosFileEntry;
import java.util.Optional;
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;
public RdosFileEntryReader(RdosFileEntry fileEntry) {
@ -52,7 +42,7 @@ public class RdosFileEntryReader implements FileEntryReader {
@Override
public Optional<String> getProdosFiletype() {
return Optional.ofNullable(FILE_TYPES.get(fileEntry.getFiletype()));
return Optional.ofNullable(fileEntry.getFormattedDisk().toProdosFiletype(fileEntry.getFiletype()));
}
@Override

View File

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