public void setPermissions(File file, ZTFilePermissions permissions) { setExecutable(file, permissions.isOwnerCanExecute(), !permissions.isGroupCanExecute() && !permissions.isOthersCanExecute()); setWritable(file, permissions.isOwnerCanWrite(), !permissions.isGroupCanWrite() && !permissions.isOthersCanWrite()); setReadable(file, permissions.isOwnerCanRead(), !permissions.isGroupCanRead() && !permissions.isOthersCanRead()); }
public boolean act(File tmpFile) { return replaceEntry(zip, new ByteSource(path, bytes), tmpFile); } });
public boolean act(File tmpFile) { return replaceEntry(zip, new FileSource(path, file), tmpFile); } });
public boolean act(File tmpFile) { addOrReplaceEntries(zip, entries, tmpFile); return true; } });
/** * Rethrow the given exception as a runtime exception. */ static ZipException rethrow(IOException e) { throw new ZipException(e); }
/** * Adds a file entry. If given file is a dir, adds it and all subfiles recursively. * Adding takes precedence over removal of entries. * * @param file file to add. * @param filter a filter to accept files for adding, null means all files are accepted * @return this Zips for fluent api */ public Zips addFile(File file, FileFilter filter) { return this.addFile(file, false, filter); }
public boolean act(File tmpFile) { addEntry(zip, entry, tmpFile); return true; } });
/** * Static factory method to obtain an instance of Zips. * * @param src zip file to process * @return instance of Zips */ public static Zips get(File src) { return new Zips(src); }
public Java6FileApiPermissionsStrategy() throws ZipException { canExecuteMethod = ZTZipReflectionUtil.getDeclaredMethod(File.class, "canExecute"); setExecutableMethod = ZTZipReflectionUtil.getDeclaredMethod(File.class, "setExecutable", boolean.class, boolean.class); setReadableMethod = ZTZipReflectionUtil.getDeclaredMethod(File.class, "setReadable", boolean.class, boolean.class); setWritableMethod = ZTZipReflectionUtil.getDeclaredMethod(File.class, "setWritable", boolean.class, boolean.class); }
/** * Creates a ZipFile from src and charset of this object. If a constructor with charset is * not available, throws an exception. * * @return ZipFile * @throws IOException if ZipFile cannot be constructed * @throws IllegalArgumentException if accessing constructor ZipFile(File, Charset) * */ private ZipFile getZipFile() throws IOException { return ZipFileUtil.getZipFile(src, charset); }
/** * Construct java.nio.file.Path object from abstract path. * Invokes JDK7 <code>file.toPath()</code> method through reflection. * * @param file * @return instance of java.nio.file.Path object */ private Object toPath(File file) { return ZTZipReflectionUtil.invoke(toPathMethod, file); }
/** * Copy entry * * @param original - zipEntry to copy * @return copy of the original entry */ static ZipEntry copy(ZipEntry original) { return copy(original, null); }
private static ZTFilePermissionsStrategy fetchDefaultStrategy() { ZTFilePermissionsStrategy strategy = tryInstantiateStrategy(Java7Nio2ApiPermissionsStrategy.class); if (strategy == null) { strategy = tryInstantiateStrategy(Java6FileApiPermissionsStrategy.class); } if (strategy == null) { strategy = NOP_STRATEGY; } return strategy; }
public boolean act(File tmpFile) { return replaceEntry(zip, new ByteSource(path, bytes, compressionMethod), tmpFile); } });
/** * Adds a file entry. If given file is a dir, adds it and all subfiles recursively. * Adding takes precedence over removal of entries. * * @param file file to add. * @return this Zips for fluent api */ public Zips addFile(File file) { return addFile(file, false, null); }
public boolean act(File tmpFile) { addEntry(zip, path, bytes, tmpFile, compressionMethod); return true; } });
/** * Static factory method to obtain an instance of Zips without source file. * See {@link #get(File src)}. * * @return instance of Zips */ public static Zips create() { return new Zips(null); }