Skip to content

Commit c8f5fe6

Browse files
committed
OpenFile: explain why location resolution is used
1 parent bb100ee commit c8f5fe6

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/main/java/org/scijava/plugins/commands/io/OpenFile.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public class OpenFile extends ContextCommand {
8080
@Override
8181
public void run() {
8282
try {
83+
// NB: You might think we should always wrap the inputFile into a
84+
// FileLocation, since it's... well... a File. But there are cases
85+
// where a file path on disk ends up getting resolved into a non-file
86+
// location. In particular, filenames ending in .fake are handled by
87+
// SCIFIO's TestImgLocationResolver (when SCIFIO is part of the
88+
// SciJava context, of course), to provide backward compatibility with
89+
// the Bio-Formats-style test image mechanism. So we pass the absolute
90+
// file path as a string to the IOService so that the location
91+
// resolution mechanism can construct the correct Location object.
8392
final String source = inputFile.getAbsolutePath();
8493
final IOPlugin<?> opener = ioService.getOpener(source);
8594
if (opener == null) {

0 commit comments

Comments
 (0)