Changeset 32642 in osm for applications
- Timestamp:
- 2016-07-12T17:28:07+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtil.java
r32374 r32642 146 146 try (FileInputStream fis = new FileInputStream(f)) { 147 147 int numBytes = fis.read(magic); 148 return Arrays.equals(JFIF_MAGIC, Arrays.copyOf(magic, Math.min(numBytes, JFIF_MAGIC.length))) 149 || Arrays.equals(PNG_MAGIC, Arrays.copyOf(magic, Math.min(numBytes, PNG_MAGIC.length))); 148 return numBytes >= 0 && ( 149 Arrays.equals(JFIF_MAGIC, Arrays.copyOf(magic, Math.min(numBytes, JFIF_MAGIC.length))) 150 || Arrays.equals(PNG_MAGIC, Arrays.copyOf(magic, Math.min(numBytes, PNG_MAGIC.length))) 151 ); 150 152 } catch (FileNotFoundException e) { 151 153 return false; 152 154 } catch (IOException e) { 155 Main.warn("IO-exception while reading file "+f.getAbsolutePath()); 153 156 return false; 154 157 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtilsTest.java
r32593 r32642 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertTrue; 6 7 … … 91 92 } 92 93 94 @Test 95 public void testFileFilterAgainstEmptyFile() throws URISyntaxException { 96 File f = new File(ImageUtil.class.getResource("/zeroByteFile").toURI()); 97 assertFalse(ImageUtil.IMAGE_FILE_FILTER.accept(f)); 98 } 99 93 100 }
Note:
See TracChangeset
for help on using the changeset viewer.