Changeset 8202 in josm
- Timestamp:
- 2015-04-17T20:55:39+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r7865 r8202 10 10 import java.io.BufferedReader; 11 11 import java.io.File; 12 import java.io.FilenameFilter; 12 13 import java.io.IOException; 13 14 import java.nio.charset.StandardCharsets; … … 102 103 private boolean recordHistory = false; 103 104 104 public OpenFileTask(List<File> files, FileFilter fileFilter, String title) { 105 public OpenFileTask(final List<File> files, final FileFilter fileFilter, final String title) { 105 106 super(title, false /* don't ignore exception */); 106 this.files = new ArrayList<>(files);107 107 this.fileFilter = fileFilter; 108 this.files = new ArrayList<>(files.size()); 109 for (final File file : files) { 110 if (file.exists()) { 111 this.files.add(file); 112 } else { 113 // try to guess an extension using the specified fileFilter 114 final File[] matchingFiles = file.getParentFile().listFiles(new FilenameFilter() { 115 @Override 116 public boolean accept(File dir, String name) { 117 return name.startsWith(file.getName()) && fileFilter.accept(new File(dir, name)); 118 } 119 }); 120 if (matchingFiles.length == 1) { 121 // use the unique match as filename 122 this.files.add(matchingFiles[0]); 123 } else { 124 // add original filename for error reporting later on 125 this.files.add(file); 126 } 127 } 128 } 108 129 } 109 130
Note:
See TracChangeset
for help on using the changeset viewer.