Added ReadableFile#size()

This commit is contained in:
Sebastian Stenzel
2016-01-09 16:39:14 +01:00
parent 0c42392244
commit fcf4476ae3
10 changed files with 53 additions and 6 deletions
@@ -55,6 +55,11 @@ class InMemoryReadableFile implements ReadableFile {
}
}
@Override
public long size() throws UncheckedIOException {
return contentGetter.get().limit();
}
@Override
public void position(long position) throws UncheckedIOException {
assert position < Integer.MAX_VALUE : "Can not use that big in-memory files.";
@@ -103,6 +103,11 @@ public class InMemoryFileSystemTest {
}
Assert.assertTrue(fooFile.exists());
// check if size = 11 bytes
try (ReadableFile readable = fooFile.openReadable()) {
Assert.assertEquals(11, readable.size());
}
// copy foo to bar
File barFile = fs.file("bar.txt");
try (WritableFile writable = barFile.openWritable()) {