2 * Copyright 2000-2007 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
.vcs
;
18 import com
.intellij
.openapi
.editor
.Document
;
19 import com
.intellij
.openapi
.fileTypes
.FileType
;
20 import com
.intellij
.openapi
.project
.Project
;
21 import com
.intellij
.openapi
.vfs
.VirtualFile
;
22 import org
.jetbrains
.annotations
.NotNull
;
23 import org
.jetbrains
.annotations
.Nullable
;
26 import java
.nio
.charset
.Charset
;
29 * Represents a path to a (possibly non-existing) file on disk or in a VCS repository.
31 public interface FilePath
{
33 * @return a virtual file that corresponds to this path, or null if the virtual file is no more valid.
35 VirtualFile
getVirtualFile();
38 * @return the virtual file that corresponds to the parent file path, or null if the virtual file is no more valid.
40 VirtualFile
getVirtualFileParent();
43 * @return the {@link java.io.File} that corresponds to the path. The path might be non-existent or not local.
50 * @return the file name (without directory component)
54 String
getPresentableUrl();
57 Document
getDocument();
62 * Get character set, considering the project defaults and a virtual file
64 * @param project the project which settings will be consulted
65 * @return the character set of the file
67 Charset
getCharset(Project project
);
70 * @return the type of the file
72 FileType
getFileType();
79 * @return true if the path represents the directory
81 boolean isDirectory();
84 * Check if the provided file is an ancestor of the current file.
86 * @param parent a possible parent
87 * @param strict if false, the method also returns true if files are equal
88 * @return true if {@code this} file is ancestor of the {@code parent}.
90 boolean isUnder(FilePath parent
, boolean strict
);
93 * @return the parent path or null if there are no parent
96 FilePath
getParentPath();
99 * @return true if the path does not represents a file in the local file system
101 boolean isNonLocal();