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
;
31 import java
.io
.IOException
;
32 import java
.io
.InputStream
;
33 import java
.io
.OutputStream
;
34 import java
.util
.Collection
;
40 public class MockLocalFileSystem
extends LocalFileSystem
{
41 private final MockVirtualFileSystem myDelegate
= new MockVirtualFileSystem();
44 public VirtualFile
findFileByIoFile(final File file
) {
45 return myDelegate
.findFileByPath(FileUtil
.toSystemIndependentName(file
.getPath()));
49 public VirtualFile
findFileByIoFile(final IFile file
) {
50 return myDelegate
.findFileByPath(FileUtil
.toSystemIndependentName(file
.getPath()));
54 public VirtualFile
refreshAndFindFileByIoFile(@NotNull final File file
) {
55 return findFileByIoFile(file
);
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());
78 public WatchRequest
addRootToWatch(final @NotNull String rootPath
, final boolean toWatchRecursively
) {
79 throw new UnsupportedOperationException("'addRootToWatch' not implemented in " + getClass().getName());
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());
104 public String
getProtocol() {
105 return LocalFileSystem
.PROTOCOL
;
109 public VirtualFile
findFileByPath(@NotNull @NonNls final String path
) {
110 return myDelegate
.findFileByPath(path
);
113 public void refresh(final boolean asynchronous
) {
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
)
140 return myDelegate
.copyFile(requestor
, virtualFile
, newParent
, copyName
);
143 public String
extractRootPath(@NotNull final String path
) {
147 public boolean isCaseSensitive() {
151 public boolean exists(final VirtualFile fileOrDirectory
) {
156 public InputStream
getInputStream(final VirtualFile file
) throws IOException
{
157 throw new UnsupportedOperationException();
161 public byte[] contentsToByteArray(final VirtualFile file
) throws IOException
{
162 return ArrayUtil
.EMPTY_BYTE_ARRAY
;
165 public long getLength(final VirtualFile file
) {
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
) {
178 public boolean isDirectory(final VirtualFile file
) {
182 public boolean isWritable(final VirtualFile file
) {
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() {