Changeset 6148 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2013-08-14T13:12:50+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r6090 r6148 22 22 23 23 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.tools.Pair; 24 25 import org.openstreetmap.josm.tools.Utils; 25 26 … … 91 92 92 93 /** 93 * Replies an input stream for a file in a ZIP-file. Replies a file in the top 94 * level directory of the ZIP file which has an extension <code>extension</code>. If more 95 * than one files have this extension, the last file whose name includes <code>namepart</code> 94 * Looks for a certain entry inside a zip file and returns the entry path. 95 * 96 * Replies a file in the top level directory of the ZIP file which has an 97 * extension <code>extension</code>. If more than one files have this 98 * extension, the last file whose name includes <code>namepart</code> 96 99 * is opened. 97 100 * 98 101 * @param extension the extension of the file we're looking for 99 102 * @param namepart the name part 100 * @return an input stream. Null if this mirrored input stream doesn't represent a zip file or if 101 * there was no matching file in the ZIP file 102 */ 103 * @return The zip entry path of the matching file. Null if this mirrored 104 * input stream doesn't represent a zip file or if there was no matching 105 * file in the ZIP file. 106 */ 107 public String findZipEntryPath(String extension, String namepart) { 108 Pair<String, InputStream> ze = findZipEntryImpl(extension, namepart); 109 if (ze == null) return null; 110 return ze.a; 111 } 112 113 /** 114 * Like {@link #findZipEntryPath}, but returns the corresponding InputStream. 115 */ 116 public InputStream findZipEntryInputStream(String extension, String namepart) { 117 Pair<String, InputStream> ze = findZipEntryImpl(extension, namepart); 118 if (ze == null) return null; 119 return ze.b; 120 } 121 122 @Deprecated // use findZipEntryInputStream 103 123 public InputStream getZipEntry(String extension, String namepart) { 124 return findZipEntryInputStream(extension, namepart); 125 } 126 127 private Pair<String, InputStream> findZipEntryImpl(String extension, String namepart) { 104 128 if (file == null) 105 129 return null; 106 InputStreamres = null;130 Pair<String, InputStream> res = null; 107 131 try { 108 132 ZipFile zipFile = new ZipFile(file); … … 120 144 } 121 145 if (resentry != null) { 122 res = zipFile.getInputStream(resentry); 146 InputStream is = zipFile.getInputStream(resentry); 147 res = Pair.create(resentry.getName(), is); 123 148 } else { 124 149 Utils.close(zipFile);
Note:
See TracChangeset
for help on using the changeset viewer.