@Override public OutputSocket<? extends Entry> output( BitField<FsAccessOption> options, FsNodeName name, @CheckForNull Entry template) { return controller.output(options, name, template); }
@Override public final OutputSocket<? extends Entry> output(BitField<FsAccessOption> options, FsNodeName name, Entry template) { return controller.output(map(options), name, template); }
/** * Called to prepare writing an archive file artifact of this driver to * the node {@code name} in {@code controller} using {@code options} and * the nullable {@code template}. * <p> * This method is overridable to enable modifying the given options * before forwarding the call to the given controller. * The implementation in the class {@link FsArchiveDriver} simply forwards * the call to the given controller with the given options unaltered. * * @param options the options for accessing the file system node. * @param controller the controller to use for writing an artifact of this * driver. * @param name the node name. * @return A sink for writing an artifact of this driver. * @see #newOutput(FsModel, BitField, FsController, FsNodeName, InputService) */ protected FsOutputSocketSink sink( BitField<FsAccessOption> options, FsController controller, FsNodeName name) { return new FsOutputSocketSink(options, controller.output(options, name, null)); }
OutputSocket<?> output( TPath path, BitField<FsAccessOption> options, @CheckForNull Entry template) { return getController().output(options, path.getNodeName(), template); }
OutputStream newOutputStream(TPath path, OpenOption... options) throws IOException { return getController() .output(path.outputOptions(options), path.getNodeName(), null) .stream(null); }
/** * This implementation modifies {@code options} in the following way before * it forwards the call to {@code controller}: * <ol> * <li>{@link FsAccessOption#STORE} is set. * <li>If {@link FsAccessOption#GROW} is set, then * {@link FsAccessOption#APPEND} gets set, too, and * {@link FsAccessOption#CACHE} gets cleared. * </ol> * <p> * The resulting output socket is then wrapped in a private nested class * for an upcast in {@link #newOutput}. * Thus, when overriding this method, {@link #newOutput} should get * overridden, too. * Otherwise, a class cast exception will be thrown in {@link #newOutput}. */ @Override protected FsOutputSocketSink sink( BitField<FsAccessOption> options, final FsController controller, final FsNodeName name) { // Leave FsAccessOption.COMPRESS untouched - the driver shall be given // opportunity to get its own preferences to sort out such a conflict. options = options.set(STORE); if (options.get(GROW)) options = options.set(APPEND).clear(CACHE); return new FsOutputSocketSink(options, controller.output(options, name, null)); }
SeekableByteChannel newByteChannel( final TPath path, final Set<? extends OpenOption> options, final FileAttribute<?>... attrs) throws IOException { final FsNodeName name = path.getNodeName(); final FsController controller = getController(); if (options.isEmpty() || options.contains(StandardOpenOption.READ)) { final BitField<FsAccessOption> o = path.inputOptions(options).set(CACHE); return controller .input(o, name) .channel(null); } else { final BitField<FsAccessOption> o = path.outputOptions(options).set(CACHE); try { return controller .output(o, name, null) .channel(null); } catch (final IOException ex) { // TODO: Filter FileAlreadyExistsException. if (o.get(EXCLUSIVE) && null != controller.node(o, name)) throw (IOException) new FileAlreadyExistsException(path.toString()) .initCause(ex); throw ex; } } }