src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java
branchJEP-349-branch
changeset 57690 9316d02dd4a5
child 57717 4ce66d271065
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java	Fri Aug 09 01:18:18 2019 +0200
@@ -0,0 +1,46 @@
+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;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+// 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;
+
+    static class Priviliged extends FileAccess {
+        @Override
+        RandomAccessFile openRAF(File f, String mode) {
+            // TDOO: Implement
+            return null;
+        }
+
+        @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 {
+            return new RandomAccessFile(f, mode);
+        }
+
+        @Override
+        DirectoryStream<Path> newDirectoryStream(Path dir) throws IOException {
+            return Files.newDirectoryStream(dir);
+        }
+
+    }
+}