Example usage for com.google.common.jimfs Jimfs newFileSystem

List of usage examples for com.google.common.jimfs Jimfs newFileSystem

Introduction

In this page you can find the example usage for com.google.common.jimfs Jimfs newFileSystem.

Prototype

public static FileSystem newFileSystem(Configuration configuration) 

Source Link

Document

Creates a new in-memory file system with the given configuration.

Usage

From source file:ch.digitalfondue.stampo.command.Check.java

@Override
void runWithPaths(String inputPath, String outputhPath) {
    try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
        buildAndPrintResult(inputPath, fs);
    } catch (IOException ioe) {
        throw new IllegalStateException(ioe);
    }//from  ww  w .j  av  a2s . c  o m
}

From source file:org.elasticsearch.common.settings.KeyStoreCommandTestCase.java

public static Environment setupEnv(boolean posix, List<FileSystem> fileSystems) throws IOException {
    final Configuration configuration;
    if (posix) {//w  w  w. j  a  v  a2  s  .c  o  m
        configuration = Configuration.unix().toBuilder().setAttributeViews("basic", "owner", "posix", "unix")
                .build();
    } else {
        configuration = Configuration.unix();
    }
    FileSystem fs = Jimfs.newFileSystem(configuration);
    fileSystems.add(fs);
    PathUtilsForTesting.installMock(fs); // restored by restoreFileSystem in ESTestCase
    Path home = fs.getPath("/", "test-home");
    Files.createDirectories(home.resolve("config"));
    return new Environment(Settings.builder().put("path.home", home).build());
}

From source file:cz.muni.fi.editor.commons.CommonsConfiguration.java

@Bean
public FileSystemProvider fileSystemProvider() {
    FileSystemProviderImpl fsp = new FileSystemProviderImpl();
    if (environment.acceptsProfiles("!test")) {
        fsp.setFileSystem(FileSystems.getDefault());
    } else {/*w  w w.java2 s.  c  o  m*/
        fsp.setFileSystem(Jimfs.newFileSystem(com.google.common.jimfs.Configuration.unix()));
    }

    return fsp;
}

From source file:com.android.repository.testframework.MockFileOp.java

private static FileSystem createFileSystem() {
    // TODO: use the current platform configuration and get rid of all the agnostic path stuff.
    Configuration config = Configuration.unix();
    config = config.toBuilder().setWorkingDirectory("/").setAttributeViews("posix").build();
    return Jimfs.newFileSystem(config);
}

From source file:com.dmdirc.tests.JimFsRule.java

@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override//from   www  .  j  a  v a 2s . co m
        public void evaluate() throws Throwable {
            fileSystem = Jimfs.newFileSystem(Configuration.unix());
            try {
                base.evaluate();
            } finally {
                fileSystem.close();
            }
        }
    };
}

From source file:natalia.dymnikova.test.WithMemFs.java

@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override/* w  w w . j ava  2 s  .  com*/
        public void evaluate() throws Throwable {
            fs = Jimfs
                    .newFileSystem(Configuration.unix().toBuilder().setAttributeViews("basic", "user").build());

            try {
                base.evaluate();
            } finally {
                fs.close();
            }
        }
    };
}

From source file:com.google.errorprone.ErrorProneInMemoryFileManager.java

private ErrorProneInMemoryFileManager(Optional<Class<?>> clazz) {
    super(new Context(), false, UTF_8);
    this.fileSystem = Jimfs.newFileSystem(Configuration.unix());
    this.clazz = clazz;
}

From source file:com.google.devtools.build.buildjar.javac.testing.InMemoryJavaFileManager.java

public InMemoryJavaFileManager() {
    super(makeContext(), false, UTF_8);
    this.fileSystem = Jimfs.newFileSystem(Configuration.unix());
    setDefaultFileSystem(fileSystem);
}

From source file:net.vs49688.rafview.vfs.RAFS.java

/**
 * Constructs a new, empty VFS/*from w w w  .  j a v  a2 s .c  o  m*/
 */
public RAFS() {
    m_NotifyDispatch = new _NotifyDispatch();
    m_Notify = new ArrayList<>();

    m_FileSystem = Jimfs.newFileSystem(m_sConfiguration);

    m_VersionData = new HashMap<>();

    m_DataFiles = new HashMap<>();
}

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 {//from  w ww  .j a va  2s  .  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());
        }
    };
}