Skip to content

Commit 1c7c64d

Browse files
author
Gary Gregory
committed
Initialize current FS once.
1 parent d42b928 commit 1c7c64d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/java/org/apache/commons/io/FileSystem.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,17 @@ public enum FileSystem {
124124
*/
125125
private static final boolean IS_OS_WINDOWS = getOsMatchesName(OS_NAME_WINDOWS_PREFIX);
126126

127+
/**
128+
* The current FileSystem.
129+
*/
130+
private static final FileSystem CURRENT = current();
131+
127132
/**
128133
* Gets the current file system.
129134
*
130135
* @return the current file system
131136
*/
132-
public static FileSystem getCurrent() {
137+
private static FileSystem current() {
133138
if (IS_OS_LINUX) {
134139
return LINUX;
135140
}
@@ -142,6 +147,15 @@ public static FileSystem getCurrent() {
142147
return GENERIC;
143148
}
144149

150+
/**
151+
* Gets the current file system.
152+
*
153+
* @return the current file system
154+
*/
155+
public static FileSystem getCurrent() {
156+
return CURRENT;
157+
}
158+
145159
/**
146160
* Decides if the operating system matches.
147161
*

0 commit comments

Comments
 (0)