OutputSocket<?> getOutputSocket(TPath path, BitField<FsOutputOption> options, @CheckForNull Entry template) { return getController() .getOutputSocket(path.getEntryName(), options, template); }
void checkAccess(final TPath path, final AccessMode... modes) throws IOException { final FsEntryName name = path.getEntryName(); final FsController<?> controller = getController(); if (null == controller.getEntry(name)) throw new NoSuchFileException(path.toString()); for (final AccessMode m : modes) { switch (m) { case READ: if (!controller.isReadable(name)) throw new AccessDeniedException(path.toString()); break; case WRITE: if (!controller.isWritable(name)) throw new AccessDeniedException(path.toString()); break; case EXECUTE: if (!controller.isExecutable(name)) throw new AccessDeniedException(path.toString()); break; default: throw new UnsupportedOperationException(); } } }
InputSocket<?> getInputSocket( TPath path, BitField<FsInputOption> options) { return getController() .getInputSocket(path.getEntryName(), options); }
/** * Creates a new, empty file similar to its superclass implementation. * Note that this method doesn't create archive files because archive * files are virtual directories, not files! * * @see #mkdir */ @Override public boolean createNewFile() throws IOException { if (null != innerArchive) { final FsController<?> controller = innerArchive.getController(); final FsEntryName entryName = getInnerFsEntryName(); // FIXME: This is not properly isolated. if (null != controller.getEntry(entryName)) return false; controller.mknod( entryName, FILE, TConfig.get().getOutputPreferences().set(EXCLUSIVE), null); return true; } return file.createNewFile(); }
SeekableByteChannel newByteChannel( final TPath path, final Set<? extends OpenOption> options, final FileAttribute<?>... attrs) throws IOException { final FsEntryName name = path.getEntryName(); final FsController<?> controller = getController(); if (options.isEmpty() || options.contains(StandardOpenOption.READ)) { final BitField<FsInputOption> o = path.mapInput(options).set(FsInputOption.CACHE); return controller .getInputSocket(name, o) .newSeekableByteChannel(); } else { final BitField<FsOutputOption> o = path.mapOutput(options).set(FsOutputOption.CACHE); try { return controller .getOutputSocket(name, o, null) .newSeekableByteChannel(); } catch (final IOException ex) { if (o.get(EXCLUSIVE) && null != controller.getEntry(name)) throw (IOException) new FileAlreadyExistsException(path.toString()) .initCause(ex); throw ex; } } }
FsEntry getEntry(TPath path) throws IOException { return getController().getEntry(path.getEntryName()); }
InputSocket<?> srcSocket = manager .getController( srcPath.getMountPoint(), driver) .getInputSocket( srcPath.getEntryName(), BitField.noneOf(FsInputOption.class)); OutputSocket<?> dstSocket = manager .getController( dstPath.getMountPoint(), driver) .getOutputSocket( dstPath.getEntryName(), BitField.of(FsOutputOption.CREATE_PARENTS, FsOutputOption.EXCLUSIVE),
private @Nullable FsScheme getScheme() { if (this != innerArchive) return null; final FsController<?> controller = this.controller; if (null != controller) return controller.getModel().getMountPoint().getScheme(); return detector.getScheme(file.getPath()); }
void delete(TPath path) throws IOException { getController().unlink(path.getEntryName(), path.getOutputPreferences()); }
final FsController<?> controller = manager.getController(mountPoint, driver); if (null != member && null != controller.getParent()) assertThat(controller, sameInstance((Object) member.getParent())); member = controller; if (null == top) final FsMountPoint mountPoint = FsMountPoint.create(URI.create(param)); assertThat(i.next().getModel().getMountPoint(), equalTo(mountPoint));
@Override public void setTimes( final FileTime lastModifiedTime, final FileTime lastAccessTime, final FileTime createTime) throws IOException { final FsController<?> controller = getController(); final Map<Access, Long> times = new EnumMap<Access, Long>( Access.class); if (null != lastModifiedTime) times.put(WRITE, lastModifiedTime.toMillis()); if (null != lastAccessTime) times.put(READ, lastAccessTime.toMillis()); if (null != createTime) times.put(CREATE, createTime.toMillis()); controller.setTime( path.getEntryName(), times, path.getOutputPreferences()); } } // FsEntryAttributeView
@Override public boolean canWrite() { if (null != innerArchive) { try { return innerArchive.getController() .isWritable(getInnerFsEntryName()); } catch (IOException ex) { return false; } } return file.canWrite(); }
@Override public boolean canRead() { if (null != innerArchive) { try { return innerArchive.getController() .isReadable(getInnerFsEntryName()); } catch (IOException ex) { return false; } } return file.canRead(); }
@Override public boolean canExecute() { if (null != innerArchive) { try { return innerArchive.getController() .isExecutable(getInnerFsEntryName()); } catch (IOException ex) { return false; } } return file.canExecute(); }
if (null != innerArchive) { try { innerArchive.getController().mknod( getInnerFsEntryName(), DIRECTORY,
/** * {@inheritDoc} * * @see <a href="#falsePositives">Detecting Archive Paths and False Positives</a> */ @Override public boolean exists() { // DONT test existance of getEnclFsEntryName() in enclArchive because // it doesn't need to exist - see // http://java.net/jira/browse/TRUEZIP-136 . if (null != innerArchive) { try { FsEntry entry = innerArchive.getController() .getEntry(getInnerFsEntryName()); return null != entry; } catch (IOException ex) { return false; } } return file.exists(); }
void createDirectory(final TPath path, final FileAttribute<?>... attrs) throws IOException { if (0 < attrs.length) throw new UnsupportedOperationException(); final FsController<?> controller = getController(); final FsEntryName name = path.getEntryName(); try { controller.mknod( name, DIRECTORY, path.getOutputPreferences(), null); } catch (IOException ex) { if (null != controller.getEntry(name)) throw (IOException) new FileAlreadyExistsException(path.toString()) .initCause(ex); throw ex; } }
FsMountPoint getMountPoint() { return getController().getModel().getMountPoint(); }
/** * Deletes the given file or directory. * If the file is a directory, it must be empty. * * @param node the file or directory. * Note that although this just needs to be a plain {@code File}, * archive files and entries are only supported for instances of * this class. * @throws IOException if any I/O error occurs. * @see <a href="#bulkIOMethods">Bulk I/O Methods</a> */ public static void rm(File node) throws IOException { if (node instanceof TFile) { TFile file = (TFile) node; if (null != file.innerArchive) { file.innerArchive.getController().unlink( file.getInnerFsEntryName(), TConfig.get().getOutputPreferences()); return; } node = file.file; } if (!node.delete()) throw new IOException(node + " (cannot delete)"); }
if (null != innerArchive) { try { innerArchive.getController().setTime( getInnerFsEntryName(), BitField.of(Access.WRITE),