diff --git a/platform/core-api/src/com/intellij/openapi/vfs/StandardFileSystems.java b/platform/core-api/src/com/intellij/openapi/vfs/StandardFileSystems.java new file mode 100644 index 000000000000..6cd6dd6e008b --- /dev/null +++ b/platform/core-api/src/com/intellij/openapi/vfs/StandardFileSystems.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vfs; + +import com.intellij.openapi.util.NotNullLazyValue; +import org.jetbrains.annotations.NotNull; + +/** + * @author yole + */ +public class StandardFileSystems { + public static String FILE_PROTOCOL = "file"; + public static String JAR_PROTOCOL = "jar"; + + private static final NotNullLazyValue ourLocal = new NotNullLazyValue() { + @NotNull + @Override + protected VirtualFileSystem compute() { + return VirtualFileManager.getInstance().getFileSystem(FILE_PROTOCOL); + } + }; + + private static final NotNullLazyValue ourJar = new NotNullLazyValue() { + @NotNull + @Override + protected VirtualFileSystem compute() { + return VirtualFileManager.getInstance().getFileSystem(JAR_PROTOCOL); + } + }; + + public static VirtualFileSystem local() { + return ourLocal.getValue(); + } + + public static VirtualFileSystem jar() { + return ourJar.getValue(); + } +} diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java index fc795a033f0d..eeb8e1474ad2 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.openapi.vfs.impl.jar; import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem; +import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -33,7 +34,7 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem { @NotNull @Override public String getProtocol() { - return "jar"; + return StandardFileSystems.JAR_PROTOCOL; } @Override diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/local/CoreLocalFileSystem.java b/platform/core-impl/src/com/intellij/openapi/vfs/local/CoreLocalFileSystem.java index 6f873aba32e0..b453cef83b90 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/local/CoreLocalFileSystem.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/local/CoreLocalFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.openapi.vfs.local; import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem; +import com.intellij.openapi.vfs.StandardFileSystems; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -30,7 +31,7 @@ public class CoreLocalFileSystem extends DeprecatedVirtualFileSystem { @NotNull @Override public String getProtocol() { - return "file"; + return StandardFileSystems.FILE_PROTOCOL; } @Override diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java index 29a4a79af77e..cb6706b66f53 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/JarFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import java.io.IOException; import java.util.zip.ZipFile; public abstract class JarFileSystem extends NewVirtualFileSystem { - @NonNls public static final String PROTOCOL = "jar"; + @NonNls public static final String PROTOCOL = StandardFileSystems.JAR_PROTOCOL; @NonNls public static final String PROTOCOL_PREFIX = "jar://"; @NonNls public static final String JAR_SEPARATOR = "!/"; diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java index 900c009995ad..b0bd675cb721 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java @@ -31,7 +31,7 @@ import java.util.Set; import static java.util.Collections.singleton; public abstract class LocalFileSystem extends NewVirtualFileSystem { - @NonNls public static final String PROTOCOL = "file"; + @NonNls public static final String PROTOCOL = StandardFileSystems.FILE_PROTOCOL; @NonNls public static final String PROTOCOL_PREFIX = PROTOCOL + "://"; @SuppressWarnings("UtilityClassWithoutPrivateConstructor")