Changeset 19372 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2025-04-02T17:09:56+02:00 (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r19211 r19372 316 316 */ 317 317 public String findZipEntryPath(String extension, String namepart) { 318 Pair<String, InputStream> ze = findZipEntryImpl(extension, namepart); 318 Pair<String, Pair<ZipFile, InputStream>> ze = findZipEntryImpl(extension, namepart); 319 319 if (ze == null) return null; 320 Utils.close(ze.b.b); 321 Utils.close(ze.b.a); 320 322 return ze.a; 321 323 } … … 328 330 * doesn't represent a zip file or if there was no matching 329 331 * file in the ZIP file. 330 * @since 6148 331 */ 332 public InputStream findZipEntryInputStream(String extension, String namepart) { 333 Pair<String, InputStream> ze = findZipEntryImpl(extension, namepart); 332 * The returned ZipFile must be closed after use. 333 * @since 19372 334 */ 335 public Pair<ZipFile, InputStream> findZipEntryInputStream(String extension, String namepart) { 336 Pair<String, Pair<ZipFile, InputStream>> ze = findZipEntryImpl(extension, namepart); 334 337 if (ze == null) return null; 335 338 return ze.b; 336 339 } 337 340 338 private Pair<String, InputStream> findZipEntryImpl(String extension, String namepart) { 341 private Pair<String, Pair<ZipFile, InputStream>> findZipEntryImpl(String extension, String namepart) { 339 342 File file = null; 340 343 try { … … 345 348 if (file == null) 346 349 return null; 347 Pair<String, InputStream> res = null; 350 Pair<String, Pair <ZipFile, InputStream>> res = null; 348 351 try { 349 ZipFile zipFile = new ZipFile(file, StandardCharsets.UTF_8); // NOPMD352 ZipFile zipFile = new ZipFile(file, StandardCharsets.UTF_8); 350 353 ZipEntry resentry = null; 351 354 Enumeration<? extends ZipEntry> entries = zipFile.entries(); … … 358 361 } 359 362 if (resentry != null) { 360 InputStream is = zipFile.getInputStream(resentry); // NOPMD361 res = Pair.create(resentry.getName(), is);363 InputStream is = zipFile.getInputStream(resentry); 364 res = Pair.create(resentry.getName(), Pair.create(zipFile, is)); 362 365 } else { 363 366 Utils.close(zipFile);
Note:
See TracChangeset
for help on using the changeset viewer.