/** * Creates the default view of the file system using the given working directory. */ private static FileSystemView createDefaultView( Configuration config, JimfsFileStore fileStore, PathService pathService) throws IOException { JimfsPath workingDirPath = pathService.parsePath(config.workingDirectory); Directory dir = fileStore.getRoot(workingDirPath.root()); if (dir == null) { throw new IllegalArgumentException("Invalid working dir path: " + workingDirPath); } for (Name name : workingDirPath.names()) { Directory newDir = fileStore.directoryCreator().get(); fileStore.setInitialAttributes(newDir); dir.link(name, newDir); dir = newDir; } return new FileSystemView(fileStore, dir, workingDirPath); } }
/** * Creates a new directory stream for the directory located by the given path. The given * {@code basePathForStream} is that base path that the returned stream will use. This will be * the same as {@code dir} except for streams created relative to another secure stream. */ public DirectoryStream<Path> newDirectoryStream( JimfsPath dir, DirectoryStream.Filter<? super Path> filter, Set<? super LinkOption> options, JimfsPath basePathForStream) throws IOException { Directory file = (Directory) lookUpWithLock(dir, options) .requireDirectory(dir) .file(); FileSystemView view = new FileSystemView(store, file, basePathForStream); JimfsSecureDirectoryStream stream = new JimfsSecureDirectoryStream(view, filter, state()); return store.supportsFeature(Feature.SECURE_DIRECTORY_STREAM) ? stream : new DowngradedDirectoryStream(stream); }
/** * Creates the default view of the file system using the given working directory. */ private static FileSystemView createDefaultView( Configuration config, JimfsFileStore fileStore, PathService pathService) throws IOException { JimfsPath workingDirPath = pathService.parsePath(config.workingDirectory); Directory dir = fileStore.getRoot(workingDirPath.root()); if (dir == null) { throw new IllegalArgumentException("Invalid working dir path: " + workingDirPath); } for (Name name : workingDirPath.names()) { Directory newDir = fileStore.directoryCreator().get(); fileStore.setInitialAttributes(newDir); dir.link(name, newDir); dir = newDir; } return new FileSystemView(fileStore, dir, workingDirPath); } }
/** * Creates a new directory stream for the directory located by the given path. The given * {@code basePathForStream} is that base path that the returned stream will use. This will be * the same as {@code dir} except for streams created relative to another secure stream. */ public DirectoryStream<Path> newDirectoryStream( JimfsPath dir, DirectoryStream.Filter<? super Path> filter, Set<? super LinkOption> options, JimfsPath basePathForStream) throws IOException { Directory file = (Directory) lookUpWithLock(dir, options) .requireDirectory(dir) .file(); FileSystemView view = new FileSystemView(store, file, basePathForStream); JimfsSecureDirectoryStream stream = new JimfsSecureDirectoryStream(view, filter, state()); return store.supportsFeature(Feature.SECURE_DIRECTORY_STREAM) ? stream : new DowngradedDirectoryStream(stream); }