Changeset 6245 in josm for trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
- Timestamp:
- 2013-09-22T16:59:52+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r5684 r6245 85 85 } 86 86 87 private FilesessionFile;88 private boolean zip; / *true, if session file is a .joz file; false if it is a .jos file*/87 private URI sessionFileURI; 88 private boolean zip; // true, if session file is a .joz file; false if it is a .jos file 89 89 private ZipFile zipFile; 90 90 private List<Layer> layers = new ArrayList<Layer>(); … … 208 208 // relative to session file - "../" step out of the archive 209 209 String relPath = uri.getPath().substring(3); 210 return new File(sessionFile .toURI().resolve(relPath));210 return new File(sessionFileURI.resolve(relPath)); 211 211 } else { 212 212 // file inside zip archive … … 215 215 } 216 216 } else 217 return new File(sessionFile .toURI().resolve(uri));217 return new File(sessionFileURI.resolve(uri)); 218 218 } 219 219 } else … … 225 225 226 226 /** 227 * Returns true if we are reading from a .joz file. 227 * Determines if we are reading from a .joz file. 228 * @return {@code true} if we are reading from a .joz file, {@code false} otherwise 228 229 */ 229 230 public boolean isZip() { … … 278 279 } 279 280 280 private void error(String msg) throws IllegalDataException { 281 private static void error(String msg) throws IllegalDataException { 281 282 throw new IllegalDataException(msg); 282 283 } … … 530 531 progressMonitor = NullProgressMonitor.INSTANCE; 531 532 } 532 this.sessionFile = sessionFile;533 this.zip = zip;534 533 535 534 InputStream josIS = null; … … 538 537 try { 539 538 zipFile = new ZipFile(sessionFile); 540 ZipEntry josEntry = null; 541 Enumeration<? extends ZipEntry> entries = zipFile.entries(); 542 while (entries.hasMoreElements()) { 543 ZipEntry entry = entries.nextElement(); 544 if (entry.getName().toLowerCase().endsWith(".jos")) { 545 josEntry = entry; 546 break; 547 } 548 } 549 if (josEntry == null) { 550 error(tr("expected .jos file inside .joz archive")); 551 } 552 josIS = zipFile.getInputStream(josEntry); 539 josIS = getZipInputStream(zipFile); 553 540 } catch (ZipException ze) { 554 541 throw new IOException(ze); … … 562 549 } 563 550 551 loadSession(josIS, sessionFile.toURI(), zip, progressMonitor); 552 } 553 554 private static InputStream getZipInputStream(ZipFile zipFile) throws ZipException, IOException, IllegalDataException { 555 ZipEntry josEntry = null; 556 Enumeration<? extends ZipEntry> entries = zipFile.entries(); 557 while (entries.hasMoreElements()) { 558 ZipEntry entry = entries.nextElement(); 559 if (entry.getName().toLowerCase().endsWith(".jos")) { 560 josEntry = entry; 561 break; 562 } 563 } 564 if (josEntry == null) { 565 error(tr("expected .jos file inside .joz archive")); 566 } 567 return zipFile.getInputStream(josEntry); 568 } 569 570 private void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { 571 572 this.sessionFileURI = sessionFileURI; 573 this.zip = zip; 574 564 575 try { 565 576 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); … … 581 592 return (Element) els.item(0); 582 593 } 583 584 594 }
Note:
See TracChangeset
for help on using the changeset viewer.