@Override public ListenableFuture<Integer> write(final ByteBuffer src, final long position) { Util.checkNotNegative(position, "position"); if (!isOpen()) { return closedChannelFuture(); } channel.checkWritable(); return executor.submit( new Callable<Integer>() { @Override public Integer call() throws IOException { return channel.write(src, position); } }); }
private void checkLockArguments(long position, long size, boolean shared) throws IOException { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); checkOpen(); if (shared) { checkReadable(); } else { checkWritable(); } }
checkNotNull(src); checkOpen(); checkWritable();
@Override public ListenableFuture<FileLock> lock( final long position, final long size, final boolean shared) { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); if (!isOpen()) { return closedChannelFuture(); } if (shared) { channel.checkReadable(); } else { channel.checkWritable(); } return executor.submit( new Callable<FileLock>() { @Override public FileLock call() throws IOException { return tryLock(position, size, shared); } }); }
@Override public FileLock tryLock(long position, long size, boolean shared) throws IOException { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); channel.checkOpen(); if (shared) { channel.checkReadable(); } else { channel.checkWritable(); } return new JimfsFileChannel.FakeFileLock(this, position, size, shared); }
@Override public FileChannel truncate(long size) throws IOException { Util.checkNotNegative(size, "size"); checkOpen(); checkWritable(); synchronized (this) { boolean completed = false; try { if (!beginBlocking()) { return this; // AsynchronousCloseException will be thrown } file.writeLock().lockInterruptibly(); try { file.truncate(size); if (position > size) { position = size; } file.updateModifiedTime(); completed = true; } finally { file.writeLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } } return this; }
Util.checkNoneNull(buffers); checkOpen(); checkWritable();
Util.checkNotNegative(position, "position"); checkOpen(); checkWritable();
Util.checkNotNegative(count, "count"); checkOpen(); checkWritable();
@Override public ListenableFuture<Integer> write(final ByteBuffer src, final long position) { Util.checkNotNegative(position, "position"); if (!isOpen()) { return closedChannelFuture(); } channel.checkWritable(); return executor.submit( new Callable<Integer>() { @Override public Integer call() throws IOException { return channel.write(src, position); } }); }
private void checkLockArguments(long position, long size, boolean shared) throws IOException { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); checkOpen(); if (shared) { checkReadable(); } else { checkWritable(); } }
@Override public ListenableFuture<FileLock> lock( final long position, final long size, final boolean shared) { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); if (!isOpen()) { return closedChannelFuture(); } if (shared) { channel.checkReadable(); } else { channel.checkWritable(); } return executor.submit( new Callable<FileLock>() { @Override public FileLock call() throws IOException { return tryLock(position, size, shared); } }); }
checkNotNull(src); checkOpen(); checkWritable();
@Override public FileChannel truncate(long size) throws IOException { Util.checkNotNegative(size, "size"); checkOpen(); checkWritable(); synchronized (this) { boolean completed = false; try { if (!beginBlocking()) { return this; // AsynchronousCloseException will be thrown } file.writeLock().lockInterruptibly(); try { file.truncate(size); if (position > size) { position = size; } file.updateModifiedTime(); completed = true; } finally { file.writeLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } } return this; }
@Override public FileLock tryLock(long position, long size, boolean shared) throws IOException { Util.checkNotNegative(position, "position"); Util.checkNotNegative(size, "size"); channel.checkOpen(); if (shared) { channel.checkReadable(); } else { channel.checkWritable(); } return new JimfsFileChannel.FakeFileLock(this, position, size, shared); }
Util.checkNoneNull(buffers); checkOpen(); checkWritable();
Util.checkNotNegative(position, "position"); checkOpen(); checkWritable();
Util.checkNotNegative(count, "count"); checkOpen(); checkWritable();