diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
commit | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (patch) | |
tree | 2f4cc6d69645bd460aa253fdecb606d764fbd25d /platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java | |
parent | 02cf98d65c798d368fcec43ed64a001d513bdd4f (diff) | |
download | idea-1aa2e09bdbd413eacb677e9fa4b50630530d0656.tar.gz |
Snapshot idea/138.1696 from git://git.jetbrains.org/idea/community.git
Change-Id: I50c97b83a815ce635e49a38380ba5b8765e4b16a
Diffstat (limited to 'platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java')
-rw-r--r-- | platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java new file mode 100644 index 000000000000..1ca489c0d128 --- /dev/null +++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2014 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.vcs; + +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.nio.charset.Charset; + +/** + * Represents a path to a (possibly non-existing) file on disk or in a VCS repository. + */ +public interface FilePath { + /** + * @return a virtual file that corresponds to this path, or null if the virtual file is no more valid. + */ + @Nullable + VirtualFile getVirtualFile(); + + /** + * @return the virtual file that corresponds to the parent file path, or null if the virtual file is no more valid. + */ + @Nullable + VirtualFile getVirtualFileParent(); + + /** + * @return the {@link java.io.File} that corresponds to the path. The path might be non-existent or not local. + * @see #isNonLocal() + */ + @NotNull + File getIOFile(); + + /** + * @return the file name (without directory component) + */ + @NotNull + String getName(); + + String getPresentableUrl(); + + @Nullable + Document getDocument(); + + Charset getCharset(); + + /** + * Get character set, considering the project defaults and a virtual file + * + * @param project the project which settings will be consulted + * @return the character set of the file + */ + Charset getCharset(Project project); + + /** + * @return the type of the file + */ + FileType getFileType(); + + void refresh(); + + void hardRefresh(); + + @NotNull + String getPath(); + + /** + * @return true if the path represents the directory + */ + boolean isDirectory(); + + /** + * Check if the provided file is an ancestor of the current file. + * + * @param parent a possible parent + * @param strict if false, the method also returns true if files are equal + * @return true if {@code this} file is ancestor of the {@code parent}. + */ + boolean isUnder(@NotNull FilePath parent, boolean strict); + + /** + * @return the parent path or null if there are no parent + */ + @Nullable + FilePath getParentPath(); + + /** + * @return true if the path does not represents a file in the local file system + */ + boolean isNonLocal(); +} |