Refactored filesystem api

* Removed Readable- and WritableBytes
** Replaced with Readable-/WritableByteChannel
** Methods now integrated in Readable- and WritableFile
** Replaced positioned read/write by method to set the position
This commit is contained in:
Markus Kreusch
2015-12-28 20:54:18 +01:00
parent 1804a52740
commit 356ea5c319
14 changed files with 155 additions and 131 deletions
@@ -42,11 +42,17 @@ class NioFile extends NioNode implements File {
private class ReadableView implements ReadableFile {
@Override
public void read(ByteBuffer target) throws UncheckedIOException {
public int read(ByteBuffer target) throws UncheckedIOException {
return -1;
}
@Override
public void read(ByteBuffer target, long position) throws UncheckedIOException {
public boolean isOpen() {
return false;
}
@Override
public void position(long position) throws UncheckedIOException {
}
@Override
@@ -62,11 +68,17 @@ class NioFile extends NioNode implements File {
private class WritableView implements WritableFile {
@Override
public void write(ByteBuffer source) throws UncheckedIOException {
public int write(ByteBuffer source) throws UncheckedIOException {
return -1;
}
@Override
public void write(ByteBuffer source, int position) throws UncheckedIOException {
public boolean isOpen() {
return false;
}
@Override
public void position(long position) throws UncheckedIOException {
}
@Override
@@ -1,7 +1,7 @@
package org.cryptomator.filesystem.nio;
import static java.util.stream.Collectors.toList;
import static org.cryptomator.commons.test.matcher.ContainsMatcher.containsInAnyOrder;
import static org.cryptomator.common.test.matcher.ContainsMatcher.containsInAnyOrder;
import static org.cryptomator.filesystem.FolderCreateMode.FAIL_IF_PARENT_IS_MISSING;
import static org.cryptomator.filesystem.FolderCreateMode.INCLUDING_PARENTS;
import static org.cryptomator.filesystem.nio.FilesystemSetupUtils.emptyFilesystem;
@@ -2,7 +2,7 @@ package org.cryptomator.filesystem.nio;
import static org.hamcrest.CoreMatchers.equalTo;
import org.cryptomator.commons.test.matcher.PropertyMatcher;
import org.cryptomator.common.test.matcher.PropertyMatcher;
import org.cryptomator.filesystem.File;
import org.cryptomator.filesystem.Folder;
import org.hamcrest.Matcher;