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

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

Introduction

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

Prototype

public static Configuration unix() 

Source Link

Document

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

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  w  w w  .  j a v a2  s . co 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) {/*from w w w . j  ava2 s. co 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: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  a2  s.c  o 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//from w  w w  .  j av  a 2 s .c o  m
        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:org.fao.geonet.FileSystemPool.java

public synchronized CreatedFs get(String fsId) throws IOException {
    while (openFs > MAX_FS && pool.isEmpty()) {
        try {/*from w  w w . ja  v  a  2 s .c  om*/
            this.wait(1000);
        } catch (InterruptedException e) {
            Jimfs.newFileSystem(fsId, Configuration.unix());
        }
    }

    final CreatedFs fileSystem;
    if (pool.isEmpty()) {
        openFs++;
        fileSystem = new CreatedFs(Jimfs.newFileSystem(fsId, Configuration.unix()), "nodes",
                "default_data_dir");
    } else {
        fileSystem = pool.pop();
        org.junit.Assert.assertNotNull(fileSystem);
    }

    syncWithTemplate(fileSystem);
    IO.setFileSystemThreadLocal(fileSystem.fs);

    return fileSystem;
}

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  w  w  .  ja va 2  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());
        }
    };
}