- determine available space in NIO file system (fixes #97)

- mount volumes via Finder, not via shell script. this makes creating volumes manually unnecessary
This commit is contained in:
Sebastian Stenzel
2016-02-23 21:52:27 +01:00
parent 7cb435e517
commit 2ae5abfc0a
4 changed files with 80 additions and 31 deletions
@@ -1,5 +1,7 @@
package org.cryptomator.filesystem.nio;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
@@ -18,14 +20,25 @@ public class NioFileSystem extends NioFolder implements FileSystem {
@Override
public Optional<Long> quotaUsedBytes() {
// TODO du -sh
return Optional.empty();
try {
long availableBytes = Files.getFileStore(path).getUsableSpace();
long totalBytes = Files.getFileStore(path).getTotalSpace();
return Optional.of(totalBytes - availableBytes);
} catch (IOException e) {
e.printStackTrace();
return Optional.empty();
}
}
@Override
public Optional<Long> quotaAvailableBytes() {
// TODO df -lh
return Optional.empty();
try {
long availableBytes = Files.getFileStore(path).getUsableSpace();
return Optional.of(availableBytes);
} catch (IOException e) {
e.printStackTrace();
return Optional.empty();
}
}
}