--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java Fri Aug 09 19:16:55 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java Tue Aug 13 03:58:29 2019 +0200
@@ -1,7 +1,6 @@
package jdk.jfr.internal.consumer;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.DirectoryStream;
@@ -10,37 +9,40 @@
// Protected by modular boundaries.
public abstract class FileAccess {
- public final static FileAccess PRIVILIGED = new UnPriviliged();
- // TODO: Should be changed Priviliged class
public final static FileAccess UNPRIVILIGED = new UnPriviliged();
- abstract RandomAccessFile openRAF(File f, String mode) throws FileNotFoundException;
- abstract DirectoryStream<Path> newDirectoryStream(Path repository) throws IOException;
+ public abstract RandomAccessFile openRAF(File f, String mode) throws IOException;
- static class Priviliged extends FileAccess {
- @Override
- RandomAccessFile openRAF(File f, String mode) {
- // TDOO: Implement
- return null;
- }
+ public abstract DirectoryStream<Path> newDirectoryStream(Path repository) throws IOException;
+
+ public abstract String getAbsolutePath(File f) throws IOException;
+ public abstract long length(File f) throws IOException;
+
+ public abstract long fileSize(Path p) throws IOException;
+
+ private static class UnPriviliged extends FileAccess {
@Override
- protected DirectoryStream<Path> newDirectoryStream(Path repository) {
- // TDOO: Implement
- return null;
- }
- }
-
- static class UnPriviliged extends FileAccess {
- @Override
- RandomAccessFile openRAF(File f, String mode) throws FileNotFoundException {
+ public RandomAccessFile openRAF(File f, String mode) throws IOException {
return new RandomAccessFile(f, mode);
}
@Override
- DirectoryStream<Path> newDirectoryStream(Path dir) throws IOException {
+ public DirectoryStream<Path> newDirectoryStream(Path dir) throws IOException {
return Files.newDirectoryStream(dir);
}
+ public String getAbsolutePath(File f) throws IOException {
+ return f.getAbsolutePath();
+ }
+
+ public long length(File f) throws IOException {
+ return f.length();
+ }
+
+ @Override
+ public long fileSize(Path p) throws IOException {
+ return Files.size(p);
+ }
}
}