aboutsummaryrefslogtreecommitdiff
path: root/jimfs
diff options
context:
space:
mode:
authorcgdecker <cgdecker@google.com>2016-01-15 09:21:59 -0800
committerColin Decker <cgdecker@google.com>2016-01-15 12:55:57 -0500
commitf8576afe1417e4414d5cd71f1a3723b3903646f0 (patch)
treef01893b0bd750f811d60f08b64b5c2d5b356fb2a /jimfs
parentbca9a94cfee80d7a7a4f8bec157fcbd53970357a (diff)
downloadjimfs-f8576afe1417e4414d5cd71f1a3723b3903646f0.tar.gz
Add a method for getting the Configuration that the Jimfs.newFileSystem() overloads that don't take a Configuration use.
This is primarily for allowing the user to create a modified version of that default configuration, which currently isn't possible without duplicating the logic to get the configuration. Also remove an unused constant. It's public, but it seems unlikely anyone's using it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=112255563
Diffstat (limited to 'jimfs')
-rw-r--r--jimfs/src/main/java/com/google/common/jimfs/Configuration.java24
-rw-r--r--jimfs/src/main/java/com/google/common/jimfs/Jimfs.java41
2 files changed, 39 insertions, 26 deletions
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Configuration.java b/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
index 9809e10..9178436 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
@@ -188,6 +188,30 @@ public final class Configuration {
}
/**
+ * Returns a default configuration appropriate to the current operating system.
+ *
+ * <p>More specifically, if the operating system is Windows, {@link Configuration#windows()} is
+ * returned; if the operating system is Mac OS X, {@link Configuration#osX()} is returned;
+ * otherwise, {@link Configuration#unix()} is returned.
+ *
+ * <p>This is the configuration used by the {@code Jimfs.newFileSystem} methods that do not take
+ * a {@code Configuration} parameter.
+ *
+ * @since 1.1
+ */
+ public static Configuration forCurrentPlatform() {
+ String os = System.getProperty("os.name");
+
+ if (os.contains("Windows")) {
+ return windows();
+ } else if (os.contains("OS X")) {
+ return osX();
+ } else {
+ return unix();
+ }
+ }
+
+ /**
* Creates a new mutable {@link Configuration} builder using the given path type.
*/
public static Builder builder(PathType pathType) {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java b/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
index f7fced7..5ab6e7a 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
@@ -77,29 +77,29 @@ public final class Jimfs {
*/
public static final String URI_SCHEME = "jimfs";
- /**
- * The key used for mapping to the {@link Configuration} in the {@code env} map when creating a
- * new file system instance using {@code FileSystems.newFileSystem()}.
- */
- public static final String CONFIG_KEY = "config";
-
private Jimfs() {}
/**
- * Creates a new in-memory file system with a default configuration appropriate to the current
- * operating system. More specifically, if the operating system is Windows,
- * {@link Configuration#windows()} is used; if the operating system is Mac OS X,
- * {@link Configuration#osX()} is used; otherwise, {@link Configuration#unix()} is used.
+ * Creates a new in-memory file system with a
+ * {@linkplain Configuration#forCurrentPlatform() default configuration} appropriate to the
+ * current operating system.
+ *
+ * <p>More specifically, if the operating system is Windows, {@link Configuration#windows()} is
+ * used; if the operating system is Mac OS X, {@link Configuration#osX()} is used; otherwise,
+ * {@link Configuration#unix()} is used.
*/
public static FileSystem newFileSystem() {
return newFileSystem(newRandomFileSystemName());
}
/**
- * Creates a new in-memory file system with a default configuration appropriate to the current
- * operating system. More specifically, if the operating system is Windows,
- * {@link Configuration#windows()} is used; if the operating system is Mac OS X,
- * {@link Configuration#osX()} is used; otherwise, {@link Configuration#unix()} is used.
+ * Creates a new in-memory file system with a
+ * {@linkplain Configuration#forCurrentPlatform() default configuration} appropriate to the
+ * current operating system.
+ *
+ * <p>More specifically, if the operating system is Windows, {@link Configuration#windows()} is
+ * used; if the operating system is Mac OS X, {@link Configuration#osX()} is used; otherwise,
+ * {@link Configuration#unix()} is used.
*
* <p>The returned file system uses the given name as the host part of its URI and the URIs of
* paths in the file system. For example, given the name {@code my-file-system}, the file
@@ -107,18 +107,7 @@ public final class Jimfs {
* will be {@code jimfs://my-file-system/foo/bar}.
*/
public static FileSystem newFileSystem(String name) {
- String os = System.getProperty("os.name");
-
- Configuration config;
- if (os.contains("Windows")) {
- config = Configuration.windows();
- } else if (os.contains("OS X")) {
- config = Configuration.osX();
- } else {
- config = Configuration.unix();
- }
-
- return newFileSystem(name, config);
+ return newFileSystem(name, Configuration.forCurrentPlatform());
}
/**