/** * Returns archive name or <code>null</code> if entry is not inside archived file. */ public String getArchiveName() { if (zipFile != null) { return zipFile.getName(); } return null; }
@Override public String toString() { if (isFromZip) { return "FileMap{" + "zipFile=" + zipFile.getName() + ", zipEntry=" + zipEntry + '}'; } else { return "FileMap{" + "mFileName='" + mFileName + '\'' + '}'; } } }
/** * Returns archive name or <code>null</code> if entry is not inside archived file. */ public String archiveName() { if (zipFile != null) { return zipFile.getName(); } return null; }
@Override public String toString() { return jarFile.getName(); } }
@Override public String toString() { return jarFile.getName(); } }
public String getPath() { return jarFile.getName(); }
@Override public String toString() { return zipFile.getName(); } }
public String getPath() { return jarFile.getName(); }
@Override public String getURL() { return zipFile.getName(); }
@Override public String getPathName() { return zipFile.getName(); }
@Override public String getNiceFileName(boolean shortNames, String inputFileName) { // FIXME: this could probably be done better return zipFile.getName() + ":" + zipEntry.getName(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((zipEntry == null) ? 0 : zipEntry.getName().hashCode()); result = prime * result + ((zipFile == null) ? 0 : zipFile.getName().hashCode()); return result; }
@Override public String toString() { return new StringBuilder(ZipDataSource.class.getSimpleName()) .append('[') .append(zipFile.getName()) .append('!') .append(zipEntry.getName()) .append(']') .toString(); }
private ZipEntry getSingleSuitableEntry( ZipFile zipFile ) throws IOException { List<String> unsuitableEntries = new ArrayList<>(); Enumeration<? extends ZipEntry> enumeration = zipFile.entries(); ZipEntry found = null; while ( enumeration.hasMoreElements() ) { ZipEntry entry = enumeration.nextElement(); if ( entry.isDirectory() || invalidZipEntry( entry.getName() ) ) { unsuitableEntries.add( entry.getName() ); continue; } if ( found != null ) { throw new IOException( "Multiple suitable files found in zip file " + zipFile.getName() + ", at least " + found.getName() + " and " + entry.getName() + ". Only a single file per zip file is supported" ); } found = entry; } if ( found == null ) { throw new IOException( "No suitable file found in zip file " + zipFile.getName() + "." + (!unsuitableEntries.isEmpty() ? " Although found these unsuitable entries " + unsuitableEntries : "" ) ); } return found; } }
public void accept(ZipFile archive, ZipEntry zipEntry) { check(archive.getName(), zipEntry.getName().replace('\\', '/')); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ZipDataSource other = (ZipDataSource) obj; if (zipEntry == null) { if (other.zipEntry != null) { return false; } } else if (!zipEntry.getName().equals(other.zipEntry.getName())) { return false; } if (zipFile == null) { if (other.zipFile != null) { return false; } } else if (!zipFile.getName().equals(other.zipFile.getName())) { return false; } return true; } }
/** * Opens zip entry or plain file and returns its input stream. */ public InputStream openInputStream() { if (zipFile != null) { try { inputStream = zipFile.getInputStream(zipEntry); return inputStream; } catch (IOException ioex) { throw new FindFileException("Input stream error: '" + zipFile.getName() + "', entry: '" + zipEntry.getName() + "'." , ioex); } } try { inputStream = new FileInputStream(file); return inputStream; } catch (FileNotFoundException fnfex) { throw new FindFileException("Unable to open: " + file.getAbsolutePath(), fnfex); } }
public boolean selectCompilationUnit(String canonicalName) throws IOException { ZipFile zipFile = null; boolean success = false; try{ zipFile = new ZipFile(file); String name = canonicalName.replace('.', '/'); // ZipFiles always use '/' as separator name = name + fileSuffix(); if(set.contains(name)) { ZipEntry zipEntry = zipFile.getEntry(name); if(zipEntry != null && !zipEntry.isDirectory()) { is = new ZipEntryInputStreamWrapper(zipFile,zipEntry); age = zipEntry.getTime(); pathName = zipFile.getName(); relativeName = name + fileSuffix(); fullName = canonicalName; success = true; } } } finally { if(zipFile != null && !success) zipFile.close(); } return success; }
/** * Opens zip entry or plain file and returns its input stream. */ public InputStream openInputStream() { if (inputStream != null) { return inputStream; } if (zipFile != null && zipEntry != null) { try { inputStream = zipFile.getInputStream(zipEntry); return inputStream; } catch (IOException ioex) { throw new FindFileException("Input stream error: '" + zipFile.getName() + "', entry: '" + zipEntry.getName() + "'." , ioex); } } if (file != null) { try { inputStream = new FileInputStream(file); return inputStream; } catch (FileNotFoundException fnfex) { throw new FindFileException("Unable to open: " + file.getAbsolutePath(), fnfex); } } throw new FindFileException("Unable to open stream: " + name()); }
ZipFileRO zipFileRO = ZipFileRO.open(zip_handle_.zipFile.getName()); ZipEntryRO entry; entry = zipFileRO.findEntryByName(name);