|
30 | 30 |
|
31 | 31 | package org.scijava.table.io; |
32 | 32 |
|
| 33 | +import java.io.File; |
33 | 34 | import java.io.IOException; |
34 | 35 | import java.util.ArrayList; |
35 | 36 | import java.util.Arrays; |
|
45 | 46 | import org.scijava.io.AbstractIOPlugin; |
46 | 47 | import org.scijava.io.handle.DataHandle; |
47 | 48 | import org.scijava.io.handle.DataHandleService; |
| 49 | +import org.scijava.io.location.FileLocation; |
48 | 50 | import org.scijava.io.location.Location; |
49 | 51 | import org.scijava.plugin.Parameter; |
50 | 52 | import org.scijava.plugin.Plugin; |
@@ -75,14 +77,13 @@ public class DefaultTableIOPlugin extends AbstractIOPlugin<Table> implements |
75 | 77 |
|
76 | 78 | @Override |
77 | 79 | public boolean supportsOpen(final Location source) { |
78 | | - final String ext = FileUtils.getExtension(source.getName()).toLowerCase(); |
79 | | - return SUPPORTED_EXTENSIONS.contains(ext); |
| 80 | + if (!(source instanceof FileLocation)) return false; |
| 81 | + return supportsOpen(((FileLocation) source).getFile()); |
80 | 82 | } |
81 | 83 |
|
82 | 84 | @Override |
83 | 85 | public boolean supportsOpen(final String source) { |
84 | | - final String ext = FileUtils.getExtension(source).toLowerCase(); |
85 | | - return SUPPORTED_EXTENSIONS.contains(ext); |
| 86 | + return supportsOpen(new File(source)); |
86 | 87 | } |
87 | 88 |
|
88 | 89 | @Override |
@@ -280,6 +281,12 @@ public void save(final Table table, final Location destination, |
280 | 281 | save(table, destination, options.values); |
281 | 282 | } |
282 | 283 |
|
| 284 | + private boolean supportsOpen(final File file) { |
| 285 | + if (!file.exists() || file.isDirectory()) return false; |
| 286 | + final String ext = FileUtils.getExtension(file).toLowerCase(); |
| 287 | + return SUPPORTED_EXTENSIONS.contains(ext); |
| 288 | + } |
| 289 | + |
283 | 290 | private void save(final Table table, final Location destination, |
284 | 291 | final TableIOOptions.Values options) throws IOException |
285 | 292 | { |
|
0 commit comments