Changing import command to allow AppleSingle data fork to be 0 bytes.
This is explicitly allowed in the AppleSingle standard. #84
This commit is contained in:
parent
8ca3e27fc4
commit
6468f3af46
|
@ -276,9 +276,12 @@ public class ImportCommand extends ReadWriteDiskCommandOptions {
|
||||||
if (as.getProdosFileInfo() == null) {
|
if (as.getProdosFileInfo() == null) {
|
||||||
throw new IOException("This AppleSingle does not contain a ProDOS file.");
|
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.");
|
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();
|
ProdosFileInfo info = as.getProdosFileInfo();
|
||||||
String fileType = ProdosFormatDisk.getFiletype(info.getFileType());
|
String fileType = ProdosFormatDisk.getFiletype(info.getFileType());
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,11 @@ public class FileUtils {
|
||||||
source.getLastModificationDate().ifPresent(target::setLastModificationDate);
|
source.getLastModificationDate().ifPresent(target::setLastModificationDate);
|
||||||
|
|
||||||
if (source.getFileData().isPresent() && source.getResourceData().isPresent()) {
|
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());
|
target.setFileData(source.getFileData().get(), source.getResourceData().get());
|
||||||
} else {
|
} else {
|
||||||
|
LOG.finest(() -> String.format("Setting data fork to %d bytes.", source.getFileData().get().length));
|
||||||
source.getFileData().ifPresent(target::setFileData);
|
source.getFileData().ifPresent(target::setFileData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,12 @@ public class FileStreamer {
|
||||||
currentDisk = tuple.formattedDisk;
|
currentDisk = tuple.formattedDisk;
|
||||||
beforeDisk.accept(currentDisk);
|
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 {
|
} else {
|
||||||
if (currentDisk != null) {
|
if (currentDisk != null) {
|
||||||
afterDisk.accept(currentDisk);
|
afterDisk.accept(currentDisk);
|
||||||
|
@ -219,6 +225,10 @@ public class FileStreamer {
|
||||||
for (FileEntry fileEntry : tuple.directoryEntry.getFiles()) {
|
for (FileEntry fileEntry : tuple.directoryEntry.getFiles()) {
|
||||||
list.add(tuple.of(fileEntry));
|
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) {
|
} catch (DiskException e) {
|
||||||
if (!ignoreErrorsFlag) {
|
if (!ignoreErrorsFlag) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
Loading…
Reference in New Issue