Implemented NioFile

* Implementation of NioFile methods
* Extracted Readable/WritableNioFile into separate classes
** Created SharedFileChannel to allow Readable/WritableNioFile for the
same NioFile to use a single, shared FileChannel
* Added tests for NioFile
* Tests for Readable/WritableNioFile pending
This commit is contained in:
Markus Kreusch
2015-12-31 16:49:54 +01:00
parent 806e366a72
commit 39535d08e7
10 changed files with 838 additions and 72 deletions
@@ -11,6 +11,9 @@ package org.cryptomator.filesystem;
class Mover {
public static void move(File source, File destination) {
if (source == destination) {
return;
}
try (OpenFiles openFiles = DeadlockSafeFileOpener.withWritable(source).andWritable(destination).open()) {
openFiles.writable(source).moveTo(openFiles.writable(destination));
}
@@ -13,6 +13,13 @@ import java.time.Instant;
public interface WritableFile extends WritableByteChannel {
/**
* <p>
* Moves this file including content to another.
* <p>
* Moving a file causes itself and the target to be
* {@link WritableFile#close() closed}.
*/
void moveTo(WritableFile other) throws UncheckedIOException;
void setLastModified(Instant instant) throws UncheckedIOException;