diff --git a/app/cli-acx/src/main/java/io/github/applecommander/acx/command/ImportCommand.java b/app/cli-acx/src/main/java/io/github/applecommander/acx/command/ImportCommand.java index 75efa07..59fc68c 100644 --- a/app/cli-acx/src/main/java/io/github/applecommander/acx/command/ImportCommand.java +++ b/app/cli-acx/src/main/java/io/github/applecommander/acx/command/ImportCommand.java @@ -276,9 +276,12 @@ public class ImportCommand extends ReadWriteDiskCommandOptions { if (as.getProdosFileInfo() == null) { throw new IOException("This AppleSingle does not contain a ProDOS file."); } - if (as.getDataFork() == null || as.getDataFork().length == 0) { + if (as.getDataFork() == null) { throw new IOException("This AppleSingle does not contain a data fork."); } + if (as.getDataFork().length == 0) { + LOG.warning("This AppleSingle has a 0 byte data fork."); + } ProdosFileInfo info = as.getProdosFileInfo(); String fileType = ProdosFormatDisk.getFiletype(info.getFileType()); diff --git a/app/cli-acx/src/main/java/io/github/applecommander/acx/fileutil/FileUtils.java b/app/cli-acx/src/main/java/io/github/applecommander/acx/fileutil/FileUtils.java index 9f21e5f..9489447 100644 --- a/app/cli-acx/src/main/java/io/github/applecommander/acx/fileutil/FileUtils.java +++ b/app/cli-acx/src/main/java/io/github/applecommander/acx/fileutil/FileUtils.java @@ -114,8 +114,11 @@ public class FileUtils { source.getLastModificationDate().ifPresent(target::setLastModificationDate); if (source.getFileData().isPresent() && source.getResourceData().isPresent()) { + LOG.finest(() -> String.format("Setting data fork to %d bytes and resource fork to %d bytes.", + source.getFileData().get().length, source.getResourceData().get().length)); target.setFileData(source.getFileData().get(), source.getResourceData().get()); } else { + LOG.finest(() -> String.format("Setting data fork to %d bytes.", source.getFileData().get().length)); source.getFileData().ifPresent(target::setFileData); } } diff --git a/lib/ac-api/src/main/java/com/webcodepro/applecommander/util/filestreamer/FileStreamer.java b/lib/ac-api/src/main/java/com/webcodepro/applecommander/util/filestreamer/FileStreamer.java index 8d19380..ea51154 100644 --- a/lib/ac-api/src/main/java/com/webcodepro/applecommander/util/filestreamer/FileStreamer.java +++ b/lib/ac-api/src/main/java/com/webcodepro/applecommander/util/filestreamer/FileStreamer.java @@ -190,6 +190,12 @@ public class FileStreamer { currentDisk = tuple.formattedDisk; beforeDisk.accept(currentDisk); } + // Special case when we have a disk with no files + // This allows triggering of the before and after disk events. + if (tuple.fileEntry == null) { + files.remove(tuple); + return hasNext(); + } } else { if (currentDisk != null) { afterDisk.accept(currentDisk); @@ -219,6 +225,10 @@ public class FileStreamer { for (FileEntry fileEntry : tuple.directoryEntry.getFiles()) { list.add(tuple.of(fileEntry)); } + // Special case? If disk is empty we need to force a tuple as none is generated + if (tuple.directoryEntry == tuple.formattedDisk && tuple.directoryEntry.getFiles().isEmpty()) { + list.add(tuple); + } } catch (DiskException e) { if (!ignoreErrorsFlag) { throw new RuntimeException(e);