IDEADEV-41995
[fedora-idea.git] / platform / testFramework / src / com / intellij / mock / MockLocalFileSystem.java
blobb71894e978f60908dc42890d8680ef40ad547ee7
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.
17 package com.intellij.mock;
19 import com.intellij.openapi.util.io.FileUtil;
20 import com.intellij.openapi.vfs.LocalFileOperationsHandler;
21 import com.intellij.openapi.vfs.LocalFileSystem;
22 import com.intellij.openapi.vfs.VirtualFile;
23 import com.intellij.util.ArrayUtil;
24 import com.intellij.util.Processor;
25 import com.intellij.util.io.fs.IFile;
26 import org.jetbrains.annotations.NonNls;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
30 import java.io.File;
31 import java.io.IOException;
32 import java.io.InputStream;
33 import java.io.OutputStream;
34 import java.util.Collection;
35 import java.util.Set;
37 /**
38 * @author nik
40 public class MockLocalFileSystem extends LocalFileSystem {
41 private final MockVirtualFileSystem myDelegate = new MockVirtualFileSystem();
43 @Nullable
44 public VirtualFile findFileByIoFile(final File file) {
45 return myDelegate.findFileByPath(FileUtil.toSystemIndependentName(file.getPath()));
48 @Nullable
49 public VirtualFile findFileByIoFile(final IFile file) {
50 return myDelegate.findFileByPath(FileUtil.toSystemIndependentName(file.getPath()));
53 @Nullable
54 public VirtualFile refreshAndFindFileByIoFile(@NotNull final File file) {
55 return findFileByIoFile(file);
58 @Nullable
59 public VirtualFile refreshAndFindFileByIoFile(final IFile ioFile) {
60 return findFileByIoFile(ioFile);
63 public void refreshIoFiles(final Iterable<File> files) {
66 public void refreshFiles(final Iterable<VirtualFile> files) {
69 public byte[] physicalContentsToByteArray(final VirtualFile virtualFile) throws IOException {
70 throw new UnsupportedOperationException("'physicalContentsToByteArray' not implemented in " + getClass().getName());
73 public long physicalLength(final VirtualFile virtualFile) throws IOException {
74 throw new UnsupportedOperationException("'physicalLength' not implemented in " + getClass().getName());
77 @Nullable
78 public WatchRequest addRootToWatch(final @NotNull String rootPath, final boolean toWatchRecursively) {
79 throw new UnsupportedOperationException("'addRootToWatch' not implemented in " + getClass().getName());
82 @NotNull
83 public Set<WatchRequest> addRootsToWatch(final @NotNull Collection<String> rootPaths, final boolean toWatchRecursively) {
84 throw new UnsupportedOperationException("'addRootsToWatch' not implemented in " + getClass().getName());
87 public void removeWatchedRoots(final @NotNull Collection<WatchRequest> rootsToWatch) {
90 public void removeWatchedRoot(final @NotNull WatchRequest watchRequest) {
93 public void registerAuxiliaryFileOperationsHandler(final LocalFileOperationsHandler handler) {
96 public void unregisterAuxiliaryFileOperationsHandler(final LocalFileOperationsHandler handler) {
99 public boolean processCachedFilesInSubtree(final VirtualFile file, final Processor<VirtualFile> processor) {
100 throw new UnsupportedOperationException("'processCachedFilesInSubtree' not implemented in " + getClass().getName());
103 @NotNull
104 public String getProtocol() {
105 return LocalFileSystem.PROTOCOL;
108 @Nullable
109 public VirtualFile findFileByPath(@NotNull @NonNls final String path) {
110 return myDelegate.findFileByPath(path);
113 public void refresh(final boolean asynchronous) {
116 @Nullable
117 public VirtualFile refreshAndFindFileByPath(@NotNull final String path) {
118 return findFileByPath(path);
121 public void deleteFile(final Object requestor, @NotNull final VirtualFile vFile) throws IOException {
124 public void moveFile(final Object requestor, @NotNull final VirtualFile vFile, @NotNull final VirtualFile newParent) throws IOException {
127 public void renameFile(final Object requestor, @NotNull final VirtualFile vFile, @NotNull final String newName) throws IOException {
130 public VirtualFile createChildFile(final Object requestor, @NotNull final VirtualFile vDir, @NotNull final String fileName) throws IOException {
131 return myDelegate.createChildFile(requestor, vDir, fileName);
134 public VirtualFile createChildDirectory(final Object requestor, @NotNull final VirtualFile vDir, @NotNull final String dirName) throws IOException {
135 return myDelegate.createChildDirectory(requestor, vDir, dirName);
138 public VirtualFile copyFile(final Object requestor, @NotNull final VirtualFile virtualFile, @NotNull final VirtualFile newParent, @NotNull final String copyName)
139 throws IOException {
140 return myDelegate.copyFile(requestor, virtualFile, newParent, copyName);
143 public String extractRootPath(@NotNull final String path) {
144 return path;
147 public boolean isCaseSensitive() {
148 return false;
151 public boolean exists(final VirtualFile fileOrDirectory) {
152 return false;
155 @NotNull
156 public InputStream getInputStream(final VirtualFile file) throws IOException {
157 throw new UnsupportedOperationException();
160 @NotNull
161 public byte[] contentsToByteArray(final VirtualFile file) throws IOException {
162 return ArrayUtil.EMPTY_BYTE_ARRAY;
165 public long getLength(final VirtualFile file) {
166 return 0;
169 @NotNull
170 public OutputStream getOutputStream(final VirtualFile file, final Object requestor, final long modStamp, final long timeStamp) throws IOException {
171 throw new UnsupportedOperationException();
174 public long getTimeStamp(final VirtualFile file) {
175 return 0;
178 public boolean isDirectory(final VirtualFile file) {
179 return false;
182 public boolean isWritable(final VirtualFile file) {
183 return false;
186 public String[] list(final VirtualFile file) {
187 return new String[0];
190 public VirtualFile[] listFiles(final VirtualFile file) {
191 return new VirtualFile[0];
194 public void setTimeStamp(final VirtualFile file, final long modstamp) throws IOException {
198 public void setWritable(final VirtualFile file, final boolean writableFlag) throws IOException {
202 public int getRank() {
203 return 1;