JVM crash fix!!! (no more static fields)
[fedora-idea.git] / platform / platform-impl / src / com / intellij / openapi / vfs / impl / win32 / Win32LocalFileSystem.java
blob578aae9a04afc2c8f0990e3aa0e7305235ca185c
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.openapi.vfs.impl.win32;
18 import com.intellij.openapi.vfs.VirtualFile;
19 import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase;
20 import org.jetbrains.annotations.NotNull;
22 import java.io.FileNotFoundException;
23 import java.util.Collection;
24 import java.util.Set;
26 /**
27 * @author Dmitry Avdeev
29 public class Win32LocalFileSystem extends LocalFileSystemBase {
31 private static Win32LocalFileSystem ourSystem;
33 public static Win32LocalFileSystem getWin32Instance() {
34 if (ourSystem == null) {
35 ourSystem = new Win32LocalFileSystem();
37 return ourSystem;
40 public static void release() {
41 ourSystem = null;
44 private final Win32Kernel myKernel = new Win32Kernel();
46 private Win32LocalFileSystem() {
49 @Override
50 public String[] list(VirtualFile file) {
51 try {
52 String[] strings = myKernel.list(file.getPath());
53 //assert Arrays.asList(strings).equals(Arrays.asList(super.list(file)));
54 return strings;
56 catch (Exception e) {
57 // assert false;
58 return super.list(file);
62 @Override
63 public boolean exists(VirtualFile fileOrDirectory) {
64 if (fileOrDirectory.getParent() == null) return true;
65 boolean b = myKernel.exists(fileOrDirectory.getPath());
66 //assert b == super.exists(fileOrDirectory);
67 return b;
70 @Override
71 public boolean isDirectory(VirtualFile file) {
72 try {
73 boolean b = myKernel.isDirectory(file.getPath());
74 //assert b == super.isDirectory(file);
75 return b;
77 catch (FileNotFoundException e) {
78 // assert false;
79 return super.isDirectory(file);
83 @Override
84 public boolean isWritable(VirtualFile file) {
85 try {
86 boolean b = myKernel.isWritable(file.getPath());
87 //assert b == super.isWritable(file);
88 return b;
90 catch (FileNotFoundException e) {
91 // assert false: file;
92 return super.isWritable(file);
96 @Override
97 public long getTimeStamp(VirtualFile file) {
98 try {
99 long timeStamp = myKernel.getTimeStamp(file.getPath());
100 //assert timeStamp == super.getTimeStamp(file);
101 return timeStamp;
103 catch (FileNotFoundException e) {
104 // assert false;
105 return super.getTimeStamp(file);
109 @Override
110 public WatchRequest addRootToWatch(@NotNull String rootPath, boolean toWatchRecursively) {
111 throw new UnsupportedOperationException();
114 @NotNull
115 @Override
116 public Set<WatchRequest> addRootsToWatch(@NotNull Collection<String> rootPaths, boolean toWatchRecursively) {
117 throw new UnsupportedOperationException();
120 @Override
121 public void removeWatchedRoots(@NotNull Collection<WatchRequest> rootsToWatch) {
122 throw new UnsupportedOperationException();
125 @Override
126 public void removeWatchedRoot(@NotNull WatchRequest watchRequest) {
127 throw new UnsupportedOperationException();