@Override public void changePermission(PermissionAccess access, PermissionType permission, boolean enabled) throws IOException, UnsupportedFileOperationException { changePermissions(ByteUtils.setBit(getPermissions().getIntValue(), (permission.toInt() << (access.toInt()*3)), enabled)); }
/** * Returns the contents of the specified folder entry. * * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ protected AbstractFile[] ls(AbstractArchiveEntryFile entryFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { // Make sure the entries tree is created and up-to-date checkEntriesTree(); if(!entryFile.isBrowsable()) throw new IOException(); DefaultMutableTreeNode matchNode = entryTreeRoot.findEntryNode(entryFile.getEntry().getPath()); if(matchNode==null) throw new IOException(); return ls(matchNode, entryFile, filenameFilter, fileFilter); }
/** * This method is overridden to use the archive file's canonical path as the base path of this entry file. */ @Override public String getCanonicalPath() { // Use the archive file's canonical path and append the entry's relative path to it return archiveFile.getCanonicalPath(true)+getRelativeEntryPath(); }
/** * Returns the relative path of this entry, with respect to the archive file. The path separator of the returned * path is the one returned by {@link #getSeparator()}. As a relative path, the returned path does not start * with a separator character. * * @return the relative path of this entry, with respect to the archive file. */ public String getRelativeEntryPath() { String path = entry.getPath(); // Replace all occurrences of the entry's separator by the archive file's separator, only if the separator is // not "/" (i.e. the entry path separator). String separator = getSeparator(); if(!separator.equals("/")) path = path.replace("/", separator); return path; }
/** * Convenience method that returns the parent {@link AbstractArchiveFile} that contains this file. If this file * is an {@link AbstractArchiveFile} or an ancestor of {@link AbstractArchiveFile}, <code>this</code> is returned. * If this file is neither contained by an archive nor is an archive, <code>null</code> is returned. * * <p> * <b>Important note:</b> the returned {@link AbstractArchiveFile}, if any, may not necessarily be an * archive, as specified by {@link #isArchive()}. This is the case for files that were resolved as * {@link AbstractArchiveFile} instances based on their path, but that do not yet exist or were created as * directories. On the contrary, an existing archive will necessarily return a non-null value. * </p> * * @return the parent {@link AbstractArchiveFile} that contains this file */ public final AbstractArchiveFile getParentArchive() { if(hasAncestor(AbstractArchiveFile.class)) return getAncestor(AbstractArchiveFile.class); else if(hasAncestor(AbstractArchiveEntryFile.class)) return getAncestor(AbstractArchiveEntryFile.class).getArchiveFile(); return null; }
); entryFile.setParent(parentFile);
List<ArchiveEntry> selectedEntries = new Vector<ArchiveEntry>(); for(int i=0; i<nbFiles; i++) { selectedEntries.add((ArchiveEntry)files.elementAt(i).getAncestor(AbstractArchiveEntryFile.class).getUnderlyingFileObject());
/** * This method is overridden to use the archive file's absolute path as the base path of this entry file. */ @Override public String getAbsolutePath() { // Use the archive file's absolute path and append the entry's relative path to it return archiveFile.getAbsolutePath(true)+getRelativeEntryPath(); }