Example usage for com.google.common.jimfs Configuration windows

List of usage examples for com.google.common.jimfs Configuration windows

Introduction

In this page you can find the example usage for com.google.common.jimfs Configuration windows.

Prototype

public static Configuration windows() 

Source Link

Document

Returns the default configuration for a Windows-like file system.

Usage

From source file:com.facebook.buck.io.filesystem.impl.FakeProjectFilesystem.java

public static ProjectFilesystem createJavaOnlyFilesystem(String rootPath) {
    boolean isWindows = Platform.detect() == Platform.WINDOWS;

    Configuration configuration = isWindows ? Configuration.windows() : Configuration.unix();
    rootPath = isWindows ? "C:" + rootPath : rootPath;

    FileSystem vfs = Jimfs.newFileSystem(configuration.toBuilder().setAttributeViews("basic", "posix").build());

    Path root = vfs.getPath(rootPath);
    try {//  ww w. j  a va2 s . c  o  m
        Files.createDirectories(root);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new DefaultProjectFilesystem(root, new DefaultProjectFilesystemDelegate(root),
            DefaultProjectFilesystemFactory.getWindowsFSInstance()) {
        @Override
        public Path resolve(Path path) {
            // Avoid resolving paths from different Java FileSystems.
            return resolve(path.toString());
        }
    };
}