/** * Returns true if this entry represents a unix symlink, * in which case the entry's content contains the target path * for the symlink. * * @since 1.5 * @return true if the entry represents a unix symlink, false otherwise. */ public boolean isUnixSymlink() { return (getUnixMode() & UnixStat.FILE_TYPE_FLAG) == UnixStat.LINK_FLAG; }
@Override public synchronized PlexusIoResourceAttributes getAttributes() { int mode = PlexusIoResourceAttributes.UNKNOWN_OCTAL_MODE; if ( entry.getPlatform() == ZipArchiveEntry.PLATFORM_UNIX ) { mode = entry.getUnixMode(); if ( ( mode & UnixStat.FILE_FLAG ) == UnixStat.FILE_FLAG ) { mode = mode & ~UnixStat.FILE_FLAG; } else { mode = mode & ~UnixStat.DIR_FLAG; } } if ( attributes == null ) { attributes = new SimpleResourceAttributes( null, null, null, null, mode ); } return attributes; }
ze.getUnixMode() != 0 ? ze.getUnixMode() : null, resolveSymlink( zipFile, ze ), getFileMappers() );
/** * Returns true if this entry represents a unix symlink, * in which case the entry's content contains the target path * for the symlink. * * @since 1.5 * @return true if the entry represents a unix symlink, false otherwise. */ public boolean isUnixSymlink() { return (getUnixMode() & UnixStat.FILE_TYPE_FLAG) == UnixStat.LINK_FLAG; }
@Override public int getFileMode() { return archiveEntry.getUnixMode(); }
ze.getUnixMode() != 0 ? ze.getUnixMode() : null, resolveSymlink( zf, ze ), getFileMappers() );
@Override public int getMode() { return getEntry().getUnixMode(); } }
@Override public int getMode() { return getEntry().getUnixMode(); } }
/** * Exctracts ZIP entry into target file. Sets correct file permissions if found in ZIP entry. * @param zip * @param entry * @param target * @throws IOException */ public static void extractZipEntry(ZipFile zip, ZipArchiveEntry entry, File target) throws IOException { target.getParentFile().mkdirs(); FileOutputStream targetOutputStream = new FileOutputStream(target); IOUtils.copyLarge(zip.getInputStream(entry), targetOutputStream); IOUtils.closeQuietly(targetOutputStream); if (Files.getFileAttributeView(target.toPath(), PosixFileAttributeView.class) != null) { Files.setPosixFilePermissions(target.toPath(), getPermissionsFromUnixMode(target, entry.getUnixMode())); } }
/** * Exctracts ZIP entry into target file. Sets correct file permissions if found in ZIP entry. * @param zip * @param entry * @param target * @throws IOException */ public static void extractZipEntry(ZipFile zip, ZipArchiveEntry entry, File target) throws IOException { target.getParentFile().mkdirs(); FileOutputStream targetOutputStream = new FileOutputStream(target); IOUtils.copyLarge(zip.getInputStream(entry), targetOutputStream); IOUtils.closeQuietly(targetOutputStream); if (Files.getFileAttributeView(target.toPath(), PosixFileAttributeView.class) != null) { Files.setPosixFilePermissions(target.toPath(), getPermissionsFromUnixMode(target, entry.getUnixMode())); } }
public static void unzip(Path in, Path targetDir, boolean skipExisting, CopyOption... options) throws IOException { try (ZipFile zip = new ZipFile(in.toFile())) { Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry e = entries.nextElement(); Path p = targetDir.resolve(e.getName()); if (skipExisting && Files.exists(p)) { continue; } if (e.isDirectory()) { Files.createDirectories(p); } else { Path parent = p.getParent(); if (!Files.exists(parent)) { Files.createDirectories(parent); } try (InputStream src = zip.getInputStream(e)) { Files.copy(src, p, options); } int unixMode = e.getUnixMode(); if (unixMode <= 0) { unixMode = Posix.DEFAULT_UNIX_MODE; } Files.setPosixFilePermissions(p, Posix.posix(unixMode)); } } } }
IOUtils.closeQuietly(output); if (Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class) != null) { Files.setPosixFilePermissions(file.toPath(), getPermissionsFromUnixMode(file, entry.getUnixMode()));
private static long getMode(ArchiveEntry entry) { if (entry instanceof TarArchiveEntry) { return ((TarArchiveEntry) entry).getMode(); } else if (entry instanceof ZipArchiveEntry) { return ((ZipArchiveEntry) entry).getUnixMode(); } else if (entry instanceof CpioArchiveEntry) { return ((CpioArchiveEntry) entry).getMode(); } else if (entry instanceof ArArchiveEntry) { return ((ArArchiveEntry) entry).getMode(); } return 0; } }
IOUtils.closeQuietly(output); if (Files.getFileAttributeView(file.toPath(), PosixFileAttributeView.class) != null) { Files.setPosixFilePermissions(file.toPath(), getPermissionsFromUnixMode(file, entry.getUnixMode()));
if ((zipEntry.getUnixMode() & MASK_EXECUTABLE) != 0)
unixPermissions = zipEntry.getUnixMode(); if (zipEntry.isDirectory()) { entryDestination.mkdirs();
unixPermissions = zipEntry.getUnixMode(); if (zipEntry.isDirectory()) { entryDestination.mkdirs();
if ((zipEntry.getUnixMode() & 0100) != 0)
private void copyZipEntry(ZipFile zipFile, ZipArchiveEntry entry, File copyTo, String key) throws IOException { Cacheable forCache = new Cacheable(entry.getName(), entry.getTime()); log.debug("Checking whether {} is up to date at {}", entry.getName(), copyTo); // Check for modification if (!copyTo.exists() || !cache.isUpToDate(key, forCache)) { log.debug("Up to date check failed, copying {} to {}", entry.getName(), copyTo); ensureIsDirectory(copyTo.getParentFile()); copyAndClose(zipFile.getInputStream(entry), copyTo); if (SystemUtils.IS_OS_UNIX) { int mode = entry.getUnixMode(); if (mode > 0) { Files.setPosixFilePermissions(copyTo.toPath(), toPerms(mode)); } } cache.put(key, forCache); } }
return ((ZipArchiveEntry) entry).getUnixMode();