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; } }
void createDirectory(final TPath path, final FileAttribute<?>... attrs) throws IOException { if (0 < attrs.length) throw new UnsupportedOperationException(); final FsController controller = getController(); final FsNodeName name = path.getNodeName(); final BitField<FsAccessOption> options = path.getAccessPreferences(); try { controller.make( options, name, DIRECTORY, null); } catch (IOException ex) { if (null != controller.node(options, name)) throw (IOException) new FileAlreadyExistsException(path.toString()) .initCause(ex); throw ex; } }
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; } } }
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; } } }