public abstract class VirtualFileSystemEntry extends NewVirtualFile
VirtualFile.PropName
Modifier and Type | Field and Description |
---|---|
static VirtualFileSystemEntry[] |
EMPTY_ARRAY |
PROP_ENCODING, PROP_HIDDEN, PROP_NAME, PROP_SYMLINK_TARGET, PROP_WRITABLE
EVER_CHANGED, NEVER_CHANGED
Modifier and Type | Method and Description |
---|---|
protected char [] |
appendPathOnFileSystem(int accumulatedPathLength,
int[] positionRef) |
VirtualFile |
copy(java.lang.Object requestor,
VirtualFile newParent,
java.lang.String copyName) |
VirtualFile |
createChildData(java.lang.Object requestor,
java.lang.String name)
Creates a new file in this directory.
|
VirtualFile |
createChildDirectory(java.lang.Object requestor,
java.lang.String name)
Creates a subdirectory in this directory.
|
void |
delete(java.lang.Object requestor)
Deletes this file.
|
boolean |
equals(java.lang.Object o) |
boolean |
exists() |
NewVirtualFile |
getCanonicalFile()
Resolves all symbolic links containing in a path to this file and returns a link target.
|
java.lang.String |
getCanonicalPath()
Resolves all symbolic links containing in a path to this file and returns a path to a link target (in platform-independent format).
|
java.nio.charset.Charset |
getCharset() |
FileType |
getFileType()
Returns the
FileType of this file, or FileTypes.UNKNOWN if a type cannot be determined
(i.e. |
int |
getId() |
long |
getLength()
File length in bytes.
|
long |
getModificationStamp()
Gets modification stamp value.
|
java.lang.String |
getName()
Gets the name of this file.
|
int |
getNameId() |
java.lang.CharSequence |
getNameSequence() |
VirtualDirectoryImpl |
getParent()
Gets the parent
VirtualFile . |
java.lang.String |
getPath()
Gets the path of this file.
|
java.lang.String |
getPresentableName() |
long |
getTimeStamp()
Gets the timestamp for this file.
|
java.lang.String |
getUrl()
Returns the URL of this file.
|
int |
hashCode() |
void |
invalidate() |
boolean |
is(VFileProperty property)
Checks whether this file has a specific property.
|
boolean |
isDirty() |
boolean |
isFileIndexed() |
boolean |
isInLocalFileSystem() |
boolean |
isRecursiveOrCircularSymLink()
Returns
true if this file is a symlink that is either recursive (i.e. |
boolean |
isValid()
Checks whether this
VirtualFile is valid. |
boolean |
isWritable()
Checks whether this file could be modified.
|
void |
markClean() |
void |
markDirty() |
void |
markDirtyRecursively() |
void |
move(java.lang.Object requestor,
VirtualFile newParent)
Moves this file to another directory.
|
void |
rename(java.lang.Object requestor,
java.lang.String newName)
Renames this file to the
newName . |
void |
setFileIndexed(boolean indexed) |
void |
setModificationStamp(long modificationStamp) |
void |
setNewName(java.lang.String newName) |
void |
setParent(VirtualFile newParent) |
void |
setTimeStamp(long time) |
void |
setWritable(boolean writable) |
java.lang.String |
toString() |
void |
updateProperty(java.lang.String property,
boolean value) |
contentsToByteArray, findChild, findChildIfCached, getCachedChildren, getFileSystem, iterInDbChildren, iterInDbChildrenWithoutLoadingVfsFromOtherProjects, refresh, refreshAndFindChild
contentsToByteArray, findFileByRelativePath, findOrCreateChildData, getBOM, getChildren, getDetectedLineSeparator, getExtension, getInputStream, getModificationCount, getNameWithoutExtension, getOutputStream, getOutputStream, getPresentableUrl, isCharsetSet, isDirectory, isValidName, nameEquals, refresh, setBinaryContent, setBinaryContent, setBinaryContent, setBOM, setCharset, setCharset, setCharset, setDetectedLineSeparator, setPreloadedContentHint, storeCharset
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
public static final VirtualFileSystemEntry[] EMPTY_ARRAY
public java.lang.String getName()
VirtualFile
getName
in class VirtualFile
VirtualFile.getNameSequence()
public java.lang.CharSequence getNameSequence()
getNameSequence
in class NewVirtualFile
public final int getNameId()
public VirtualDirectoryImpl getParent()
VirtualFile
VirtualFile
.getParent
in class NewVirtualFile
null
if this file is a root directorypublic boolean isDirty()
isDirty
in class NewVirtualFile
public long getModificationStamp()
VirtualFile
getModificationStamp
in class VirtualFile
VirtualFile.getTimeStamp()
public void setModificationStamp(long modificationStamp)
public boolean isFileIndexed()
public void setFileIndexed(boolean indexed)
public void markClean()
markClean
in class NewVirtualFile
public void markDirty()
markDirty
in class NewVirtualFile
public void markDirtyRecursively()
markDirtyRecursively
in class NewVirtualFile
protected char [] appendPathOnFileSystem(int accumulatedPathLength, int[] positionRef)
public java.lang.String getUrl()
VirtualFile
Returns the URL of this file. The URL is a string that uniquely identifies a file in all file systems.
It has the following format: <protocol>://<path>
.
File can be found by its URL using VirtualFileManager.findFileByUrl(java.lang.String)
method.
Please note these URLs are intended for use withing VFS - meaning they are not necessarily RFC-compliant.
getUrl
in class VirtualFile
VirtualFileManager.findFileByUrl(java.lang.String)
,
VirtualFile.getPath()
,
VirtualFileSystem.getProtocol()
public java.lang.String getPath()
VirtualFile
VirtualFileSystem
. Format of the path depends on the concrete file system.
For LocalFileSystem
it is an absolute file path with file separator characters
(File.separatorChar
) replaced to the forward slash ('/'
).getPath
in class VirtualFile
public void delete(java.lang.Object requestor) throws java.io.IOException
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.delete
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
java.io.IOException
- if file failed to be deletedpublic void rename(java.lang.Object requestor, java.lang.String newName) throws java.io.IOException
VirtualFile
Renames this file to the newName
.
This method should only be called within write action
.
rename
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
newName
- the new file namejava.io.IOException
- if file failed to be renamedpublic VirtualFile createChildData(java.lang.Object requestor, java.lang.String name) throws java.io.IOException
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.createChildData
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
VirtualFile
representing the created filejava.io.IOException
- if file failed to be createdpublic boolean isWritable()
VirtualFile
isWritable
in class VirtualFile
true
if this file is writable, false
otherwisepublic void setWritable(boolean writable) throws java.io.IOException
setWritable
in class NewVirtualFile
java.io.IOException
public long getTimeStamp()
VirtualFile
getTimeStamp
in class VirtualFile
File.lastModified()
public void setTimeStamp(long time) throws java.io.IOException
setTimeStamp
in class NewVirtualFile
java.io.IOException
public long getLength()
VirtualFile
getLength
in class VirtualFile
public VirtualFile copy(java.lang.Object requestor, VirtualFile newParent, java.lang.String copyName) throws java.io.IOException
copy
in class VirtualFile
java.io.IOException
public void move(java.lang.Object requestor, VirtualFile newParent) throws java.io.IOException
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.move
in class NewVirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
newParent
- the directory to move this file tojava.io.IOException
- if file failed to be movedpublic int getId()
getId
in interface VirtualFileWithId
getId
in class NewVirtualFile
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public VirtualFile createChildDirectory(java.lang.Object requestor, java.lang.String name) throws java.io.IOException
VirtualFile
Application.runWriteAction(java.lang.Runnable)
.createChildDirectory
in class VirtualFile
requestor
- any object to control who called this method. Note that
it is considered to be an external change if requestor
is null
.
See VirtualFileEvent.getRequestor()
name
- directory nameVirtualFile
representing the created directoryjava.io.IOException
- if directory failed to be createdpublic boolean exists()
exists
in class VirtualFile
public boolean isValid()
VirtualFile
VirtualFile
is valid. File can be invalidated either by deleting it or one of its
parents with VirtualFile.delete(java.lang.Object)
method or by an external change.
If file is not valid only Object.equals(java.lang.Object)
, Object.hashCode()
,
VirtualFile.getName()
, VirtualFile.getPath()
, VirtualFile.getUrl()
, VirtualFile.getPresentableUrl()
and methods from
UserDataHolder
can be called for it. Using any other methods for an invalid VirtualFile
instance
produce unpredictable results.isValid
in class NewVirtualFile
true
if this is a valid file, false
otherwisepublic java.lang.String toString()
toString
in class VirtualFile
public void setNewName(java.lang.String newName)
public void setParent(VirtualFile newParent)
public boolean isInLocalFileSystem()
isInLocalFileSystem
in class VirtualFile
public void invalidate()
public java.nio.charset.Charset getCharset()
getCharset
in class VirtualFile
public java.lang.String getPresentableName()
getPresentableName
in class VirtualFile
public boolean is(VFileProperty property)
VirtualFile
is
in class VirtualFile
true
if the file has a specific property, false
otherwisepublic void updateProperty(java.lang.String property, boolean value)
public java.lang.String getCanonicalPath()
VirtualFile
Resolves all symbolic links containing in a path to this file and returns a path to a link target (in platform-independent format).
Note: please use this method judiciously. In most cases VFS clients don't need to resolve links in paths and should work with those provided by a user.
getCanonicalPath
in class VirtualFile
getPath()
if there are no symbolic links in a file's path;
getCanonicalFile().getPath()
if the link was successfully resolved;
null
otherwisepublic NewVirtualFile getCanonicalFile()
VirtualFile
Resolves all symbolic links containing in a path to this file and returns a link target.
Note: please use this method judiciously. In most cases VFS clients don't need to resolve links in paths and should work with those provided by a user.
getCanonicalFile
in class NewVirtualFile
this
if there are no symbolic links in a file's path;
instance of VirtualFile
if the link was successfully resolved;
null
otherwisepublic boolean isRecursiveOrCircularSymLink()
VirtualFile
true
if this file is a symlink that is either recursive (i.e. points to this file' parent) or
circular (i.e. its path has a form of "/.../linkX/.../linkX").isRecursiveOrCircularSymLink
in class VirtualFile
public FileType getFileType()
VirtualFile
FileType
of this file, or FileTypes.UNKNOWN
if a type cannot be determined
(i.e. file type is not registered via FileTypeRegistry
).
Performance notice: consider using FileTypeRegistry.isFileOfType(com.intellij.openapi.vfs.VirtualFile, com.intellij.openapi.fileTypes.FileType)
or FileTypeRegistry.getFileTypeByFileName(java.lang.CharSequence)
if this method is to be called for massive file collections, e.g. in BulkFileListener
. See FileTypeRegistry
javadoc
for the details.
getFileType
in class VirtualFile
FileTypeRegistry