Skip to content

Commit 8954b5b

Browse files
committed
This corrects for a naming issue if the file is given on the command line; a full directory path causes issues.
1 parent 32c1a30 commit 8954b5b

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

app/cli-acx/src/main/java/io/github/applecommander/acx/command/ImportCommand.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@
1919
*/
2020
package io.github.applecommander.acx.command;
2121

22-
import java.io.ByteArrayInputStream;
23-
import java.io.ByteArrayOutputStream;
24-
import java.io.File;
25-
import java.io.IOException;
26-
import java.io.InputStream;
27-
import java.io.UncheckedIOException;
28-
import java.nio.file.Files;
29-
import java.nio.file.Path;
30-
import java.util.*;
31-
import java.util.function.Function;
32-
import java.util.logging.Logger;
33-
3422
import com.webcodepro.applecommander.storage.DirectoryEntry;
3523
import com.webcodepro.applecommander.storage.FileEntry;
3624
import com.webcodepro.applecommander.storage.os.prodos.ProdosFormatDisk;
@@ -42,7 +30,6 @@
4230
import com.webcodepro.shrinkit.HeaderBlock;
4331
import com.webcodepro.shrinkit.NuFileArchive;
4432
import com.webcodepro.shrinkit.ThreadRecord;
45-
4633
import io.github.applecommander.acx.base.ReadWriteDiskCommandOptions;
4734
import io.github.applecommander.acx.converter.IntegerTypeConverter;
4835
import io.github.applecommander.acx.fileutil.FileUtils;
@@ -60,6 +47,13 @@
6047
import picocli.CommandLine.Option;
6148
import picocli.CommandLine.Parameters;
6249

50+
import java.io.*;
51+
import java.nio.file.Files;
52+
import java.nio.file.Path;
53+
import java.util.*;
54+
import java.util.function.Function;
55+
import java.util.logging.Logger;
56+
6357
@Command(name = "import", description = "Import file onto disk.",
6458
aliases = { "put" })
6559
public class ImportCommand extends ReadWriteDiskCommandOptions {
@@ -116,7 +110,7 @@ public int handleCommand() throws Exception {
116110
new IOException(String.format("Directory '%s' not found.", dir)));
117111
}
118112
}
119-
113+
120114
FileUtils copier = new FileUtils(overwriteFlag);
121115
FileEntryReader inputReader = inputData.get();
122116
for (FileEntryReader processorReader : processor.apply(inputReader)) {
@@ -161,7 +155,7 @@ public void fromFile(final String filename) {
161155
byte[] data = Files.readAllBytes(path);
162156
fileEntryReader = OverrideFileEntryReader.builder()
163157
.fileData(data)
164-
.filename(filename)
158+
.filename(path.getFileName().toString())
165159
.prodosFiletype("BIN")
166160
.build();
167161
} catch (IOException e) {
@@ -365,7 +359,7 @@ private List<FileEntryReader> handleShrinkitMode(FileEntryReader reader) {
365359
}
366360

367361
public static class Overrides {
368-
@Option(names = { "-t", "--type" }, description = "ProDOS File type. "
362+
@Option(names = { "-t", "--type" }, description = "ProDOS or native file type. "
369363
+ "(Each filesystem translates between it's native types and ProDOS.)")
370364
private Optional<String> fileType;
371365

app/cli-acx/src/main/java/io/github/applecommander/acx/fileutil/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void copyFile(DirectoryEntry directory, FileEntry sourceFile) throws DiskExcepti
8585
}
8686

8787
public void copyFile(DirectoryEntry directory, FileEntryReader source) throws DiskException {
88-
String sourceName = source.getFilename().get();
88+
String sourceName = source.getFilename().orElseThrow();
8989
String sanitizedName = directory.getFormattedDisk().getSuggestedFilename(sourceName);
9090
final Optional<FileEntry> fileEntry = directory.getFiles().stream()
9191
.filter(entry -> entry.getFilename().equals(sanitizedName))

0 commit comments

Comments
 (0)