public abstract class LocalFileSystemBase extends LocalFileSystem
LocalFileSystem.WatchRequest
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOG |
PROTOCOL, PROTOCOL_PREFIX
DEFAULT_LENGTH, DEFAULT_TIMESTAMP
Constructor and Description |
---|
LocalFileSystemBase() |
Modifier and Type | Method and Description |
---|---|
byte [] |
contentsToByteArray(VirtualFile file) |
VirtualFile |
copyFile(java.lang.Object requestor,
VirtualFile file,
VirtualFile newParent,
java.lang.String copyName)
Implementation of copying files in this file system
|
VirtualFile |
createChildDirectory(java.lang.Object requestor,
VirtualFile parent,
java.lang.String dir)
Implementation of adding directories in this file system
|
VirtualFile |
createChildFile(java.lang.Object requestor,
VirtualFile parent,
java.lang.String file)
Implementation of adding files in this file system
|
void |
deleteFile(java.lang.Object requestor,
VirtualFile file)
Implementation of deleting files in this file system
|
boolean |
exists(VirtualFile file) |
protected java.lang.String |
extractRootPath(java.lang.String normalizedPath)
IntelliJ platform calls this method with non-null value returned by
NewVirtualFileSystem.normalize(java.lang.String) , but if something went wrong
and an implementation can't extract a valid root path nevertheless, it should return an empty string. |
VirtualFile |
findFileByIoFile(java.io.File file) |
VirtualFile |
findFileByPath(java.lang.String path)
Searches for the file specified by given path.
|
VirtualFile |
findFileByPathIfCached(java.lang.String path) |
FileAttributes |
getAttributes(VirtualFile file)
Reads various file attributes in one shot (to reduce the number of native I/O calls).
|
java.lang.String |
getCanonicallyCasedName(VirtualFile file) |
java.io.InputStream |
getInputStream(VirtualFile file)
Does NOT strip the BOM from the beginning of the stream, unlike the
VirtualFile.getInputStream() |
long |
getLength(VirtualFile file) |
java.io.OutputStream |
getOutputStream(VirtualFile file,
java.lang.Object requestor,
long modStamp,
long timeStamp)
Does NOT add the BOM to the beginning of the stream, unlike the
VirtualFile.getOutputStream(Object) |
java.lang.String |
getProtocol()
Gets the protocol for this file system.
|
int |
getRank() |
long |
getTimeStamp(VirtualFile file) |
boolean |
hasChildren(VirtualFile file)
Returns
true if path represents a directory with at least one child. |
boolean |
isCaseSensitive() |
boolean |
isDirectory(VirtualFile file) |
boolean |
isReadOnly() |
boolean |
isSymLink(VirtualFile file) |
boolean |
isValidName(java.lang.String name) |
boolean |
isWritable(VirtualFile file) |
java.lang.String [] |
list(VirtualFile file) |
boolean |
markNewFilesAsDirty() |
void |
moveFile(java.lang.Object requestor,
VirtualFile file,
VirtualFile newParent)
Implementation of moving files in this file system
|
protected java.lang.String |
normalize(java.lang.String path)
Implementations should convert separator chars to forward slashes and remove duplicates ones,
and convert paths to "absolute" form (so that they start from a root that is valid for this FS and
could be later extracted with
NewVirtualFileSystem.extractRootPath(java.lang.String) ). |
void |
refresh(boolean asynchronous)
Refreshes the cached information for all files in this file system from the physical file system.
|
VirtualFile |
refreshAndFindFileByIoFile(java.io.File file) |
VirtualFile |
refreshAndFindFileByPath(java.lang.String path)
Refreshes only the part of the file system needed for searching the file by the given path and finds file
by the given path.
This method is useful when the file was created externally and you need to find
corresponding to it. |
void |
refreshFiles(java.lang.Iterable<? extends VirtualFile> files)
Performs a non-recursive synchronous refresh of specified files.
|
void |
refreshFiles(java.lang.Iterable<? extends VirtualFile> files,
boolean async,
boolean recursive,
java.lang.Runnable onFinish) |
void |
refreshIoFiles(java.lang.Iterable<? extends java.io.File> files)
Performs a non-recursive synchronous refresh of specified files.
|
void |
refreshIoFiles(java.lang.Iterable<? extends java.io.File> files,
boolean async,
boolean recursive,
java.lang.Runnable onFinish)
Performs the refresh of the specified files based on filesystem events that have already been received.
|
void |
registerAuxiliaryFileOperationsHandler(LocalFileOperationsHandler handler)
Registers a handler that allows a version control system plugin to intercept file operations in the local file system
and to perform them through the VCS tool.
|
void |
renameFile(java.lang.Object requestor,
VirtualFile file,
java.lang.String newName)
Implementation of renaming files in this file system
|
java.lang.String |
resolveSymLink(VirtualFile file) |
void |
setTimeStamp(VirtualFile file,
long timeStamp) |
void |
setWritable(VirtualFile file,
boolean writableFlag) |
void |
unregisterAuxiliaryFileOperationsHandler(LocalFileOperationsHandler handler)
Unregisters a handler that allows a version control system plugin to intercept file operations in the local file system
and to perform them through the VCS tool.
|
addRootsToWatch, addRootToWatch, getInstance, removeWatchedRoot, removeWatchedRoots, replaceWatchedRoot, replaceWatchedRoots
addVirtualFileListener, refreshWithoutFileWatcher, removeVirtualFileListener
extractPresentableUrl
protected static final Logger LOG
public VirtualFile findFileByPath(java.lang.String path)
VirtualFileSystem
VirtualFileSystem
. Format of the path depends on the concrete file system.
For LocalFileSystem
it is an absolute path (both Unix- and Windows-style separator chars are allowed).findFileByPath
in class VirtualFileSystem
path
- the path to find file bynull
otherwisepublic VirtualFile findFileByPathIfCached(java.lang.String path)
findFileByPathIfCached
in class NewVirtualFileSystem
public VirtualFile refreshAndFindFileByPath(java.lang.String path)
VirtualFileSystem
VirtualFile
corresponding to it.If this method is invoked not from Swing event dispatch thread, then it must not happen inside a read action. The reason is that then the method call won't return until proper VFS events are fired, which happens on Swing thread and in write action. So invoking this method in a read action would result in a deadlock.
refreshAndFindFileByPath
in class VirtualFileSystem
path
- the pathVirtualFile
if the file was found, null
otherwisepublic VirtualFile findFileByIoFile(java.io.File file)
findFileByIoFile
in class LocalFileSystem
public boolean exists(VirtualFile file)
public long getLength(VirtualFile file)
public long getTimeStamp(VirtualFile file)
public boolean isDirectory(VirtualFile file)
public boolean isWritable(VirtualFile file)
public boolean isSymLink(VirtualFile file)
isSymLink
in interface FileSystemInterface
isSymLink
in class NewVirtualFileSystem
public java.lang.String resolveSymLink(VirtualFile file)
resolveSymLink
in interface FileSystemInterface
resolveSymLink
in class NewVirtualFileSystem
public java.lang.String [] list(VirtualFile file)
public java.lang.String getProtocol()
VirtualFileSystem
KeyedLazyInstanceEP.key
.getProtocol
in class VirtualFileSystem
VirtualFile.getUrl()
,
VirtualFileManager.getFileSystem(java.lang.String)
public boolean isReadOnly()
isReadOnly
in class NewVirtualFileSystem
protected java.lang.String normalize(java.lang.String path)
NewVirtualFileSystem
Implementations should convert separator chars to forward slashes and remove duplicates ones,
and convert paths to "absolute" form (so that they start from a root that is valid for this FS and
could be later extracted with NewVirtualFileSystem.extractRootPath(java.lang.String)
).
Implementations should not normalize paths by eliminating directory traversals or other indirections.
normalize
in class NewVirtualFileSystem
null
when a path is invalid for this FS.public VirtualFile refreshAndFindFileByIoFile(java.io.File file)
refreshAndFindFileByIoFile
in class LocalFileSystem
public void refreshIoFiles(java.lang.Iterable<? extends java.io.File> files)
LocalFileSystem
refreshIoFiles
in class LocalFileSystem
files
- files to refresh.LocalFileSystem.refreshIoFiles(Iterable, boolean, boolean, Runnable)
public void refreshIoFiles(java.lang.Iterable<? extends java.io.File> files, boolean async, boolean recursive, java.lang.Runnable onFinish)
LocalFileSystem
VfsUtil.markDirtyAndRefresh(boolean, boolean, boolean, File...)
instead.refreshIoFiles
in class LocalFileSystem
public void refreshFiles(java.lang.Iterable<? extends VirtualFile> files)
LocalFileSystem
refreshFiles
in class LocalFileSystem
files
- files to refresh.public void refreshFiles(java.lang.Iterable<? extends VirtualFile> files, boolean async, boolean recursive, java.lang.Runnable onFinish)
refreshFiles
in class LocalFileSystem
public void registerAuxiliaryFileOperationsHandler(LocalFileOperationsHandler handler)
LocalFileSystem
registerAuxiliaryFileOperationsHandler
in class LocalFileSystem
handler
- the handler instance.public void unregisterAuxiliaryFileOperationsHandler(LocalFileOperationsHandler handler)
LocalFileSystem
unregisterAuxiliaryFileOperationsHandler
in class LocalFileSystem
handler
- the handler instance.public VirtualFile createChildDirectory(java.lang.Object requestor, VirtualFile parent, java.lang.String dir) throws java.io.IOException
VirtualFileSystem
createChildDirectory
in interface FileSystemInterface
createChildDirectory
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.createChildDirectory(Object,String)
public VirtualFile createChildFile(java.lang.Object requestor, VirtualFile parent, java.lang.String file) throws java.io.IOException
VirtualFileSystem
createChildFile
in interface FileSystemInterface
createChildFile
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.createChildData(Object,String)
public void deleteFile(java.lang.Object requestor, VirtualFile file) throws java.io.IOException
VirtualFileSystem
deleteFile
in interface FileSystemInterface
deleteFile
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.delete(Object)
public boolean isCaseSensitive()
isCaseSensitive
in class VirtualFileSystem
public boolean isValidName(java.lang.String name)
isValidName
in class VirtualFileSystem
public java.io.InputStream getInputStream(VirtualFile file) throws java.io.IOException
FileSystemInterface
VirtualFile.getInputStream()
java.io.IOException
public byte [] contentsToByteArray(VirtualFile file) throws java.io.IOException
java.io.IOException
public java.io.OutputStream getOutputStream(VirtualFile file, java.lang.Object requestor, long modStamp, long timeStamp) throws java.io.IOException
FileSystemInterface
VirtualFile.getOutputStream(Object)
java.io.IOException
public void moveFile(java.lang.Object requestor, VirtualFile file, VirtualFile newParent) throws java.io.IOException
VirtualFileSystem
moveFile
in interface FileSystemInterface
moveFile
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.move(Object,VirtualFile)
public void renameFile(java.lang.Object requestor, VirtualFile file, java.lang.String newName) throws java.io.IOException
VirtualFileSystem
renameFile
in interface FileSystemInterface
renameFile
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.rename(Object,String)
public VirtualFile copyFile(java.lang.Object requestor, VirtualFile file, VirtualFile newParent, java.lang.String copyName) throws java.io.IOException
VirtualFileSystem
copyFile
in interface FileSystemInterface
copyFile
in class NewVirtualFileSystem
java.io.IOException
VirtualFile.copy(Object,VirtualFile,String)
public void setTimeStamp(VirtualFile file, long timeStamp)
public void setWritable(VirtualFile file, boolean writableFlag) throws java.io.IOException
java.io.IOException
protected java.lang.String extractRootPath(java.lang.String normalizedPath)
NewVirtualFileSystem
NewVirtualFileSystem.normalize(java.lang.String)
, but if something went wrong
and an implementation can't extract a valid root path nevertheless, it should return an empty string.extractRootPath
in class NewVirtualFileSystem
public int getRank()
getRank
in class NewVirtualFileSystem
public boolean markNewFilesAsDirty()
markNewFilesAsDirty
in class NewVirtualFileSystem
public java.lang.String getCanonicallyCasedName(VirtualFile file)
getCanonicallyCasedName
in class NewVirtualFileSystem
public FileAttributes getAttributes(VirtualFile file)
NewVirtualFileSystem
getAttributes
in class NewVirtualFileSystem
file
- file to get attributes of.null
if the file doesn't exist.public void refresh(boolean asynchronous)
VirtualFileSystem
If
asynchronous
is false
this method should be only called within write-action.
See Application.runWriteAction(java.lang.Runnable)
.refresh
in class VirtualFileSystem
asynchronous
- if true
then the operation will be performed in a separate thread,
otherwise will be performed immediatelyVirtualFile.refresh(boolean, boolean)
,
VirtualFileManager.syncRefresh()
,
VirtualFileManager.asyncRefresh(java.lang.Runnable)
public boolean hasChildren(VirtualFile file)
NewVirtualFileSystem
true
if path
represents a directory with at least one child.
Override if your file system can answer this question more efficiently (e.g. without enumerating all children).hasChildren
in class NewVirtualFileSystem