Class Configuration

java.lang.Object
com.google.common.jimfs.Configuration

public final class Configuration extends Object
Immutable configuration for an in-memory file system. A Configuration is passed to a method in Jimfs such as Jimfs.newFileSystem(Configuration) to create a new FileSystem instance.
Author:
Colin Decker
  • Method Details

    • unix

      public static Configuration unix()

      Returns the default configuration for a UNIX-like file system. A file system created with this configuration:

      • uses / as the path name separator (see PathType.unix() for more information on the path format)
      • has root / and working directory /work
      • performs case-sensitive file lookup
      • supports only the basic file attribute view, to avoid overhead for unneeded attributes
      • supports hard links, symbolic links, SecureDirectoryStream and FileChannel

      To create a modified version of this configuration, such as to include the full set of UNIX file attribute views, create a builder.

      Example:

         Configuration config = Configuration.unix().toBuilder()
             .setAttributeViews("basic", "owner", "posix", "unix")
             .setWorkingDirectory("/home/user")
             .build();  
    • osX

      public static Configuration osX()

      Returns the default configuration for a Mac OS X-like file system.

      The primary differences between this configuration and the default unix() configuration are that this configuration does Unicode normalization on the display and canonical forms of filenames and does case insensitive file lookup.

      A file system created with this configuration:

      • uses / as the path name separator (see PathType.unix() for more information on the path format)
      • has root / and working directory /work
      • does Unicode normalization on paths, both for lookup and for Path objects
      • does case-insensitive (for ASCII characters only) lookup
      • supports only the basic file attribute view, to avoid overhead for unneeded attributes
      • supports hard links, symbolic links and FileChannel

      To create a modified version of this configuration, such as to include the full set of UNIX file attribute views or to use full Unicode case insensitivity, create a builder.

      Example:

         Configuration config = Configuration.osX().toBuilder()
             .setAttributeViews("basic", "owner", "posix", "unix")
             .setNameCanonicalNormalization(NFD, CASE_FOLD_UNICODE)
             .setWorkingDirectory("/Users/user")
             .build();  
    • windows

      public static Configuration windows()

      Returns the default configuration for a Windows-like file system. A file system created with this configuration:

      • uses \ as the path name separator and recognizes / as a separator when parsing paths (see PathType.windows() for more information on path format)
      • has root C:\ and working directory C:\work
      • performs case-insensitive (for ASCII characters only) file lookup
      • creates Path objects that use case-insensitive (for ASCII characters only) equality
      • supports only the basic file attribute view, to avoid overhead for unneeded attributes
      • supports hard links, symbolic links and FileChannel

      To create a modified version of this configuration, such as to include the full set of Windows file attribute views or to use full Unicode case insensitivity, create a builder.

      Example:

         Configuration config = Configuration.windows().toBuilder()
             .setAttributeViews("basic", "owner", "dos", "acl", "user")
             .setNameCanonicalNormalization(CASE_FOLD_UNICODE)
             .setWorkingDirectory("C:\\Users\\user") // or "C:/Users/user"
             .build();  
    • forCurrentPlatform

      public static Configuration forCurrentPlatform()
      Returns a default configuration appropriate to the current operating system.

      More specifically, if the operating system is Windows, windows() is returned; if the operating system is Mac OS X, osX() is returned; otherwise, unix() is returned.

      This is the configuration used by the Jimfs.newFileSystem methods that do not take a Configuration parameter.

      Since:
      1.1
    • builder

      public static Configuration.Builder builder(PathType pathType)
      Creates a new mutable Configuration builder using the given path type.
    • toBuilder

      public Configuration.Builder toBuilder()
      Returns a new mutable builder that initially contains the same settings as this configuration.