public class VfsUtil extends VfsUtilCore
VfsUtilCore.DistinctVFilesRootsCollection
Modifier and Type | Field and Description |
---|---|
static long |
NOTIFICATION_DELAY_MILLIS
Specifies an average delay between a file system event and a moment the IDE gets pinged about it by fsnotifier.
|
LOCALHOST_URI_PATH_PREFIX, VFS_SEPARATOR, VFS_SEPARATOR_CHAR
Constructor and Description |
---|
VfsUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<VirtualFile> |
collectChildrenRecursively(VirtualFile root) |
static VirtualFile |
copy(java.lang.Object requestor,
VirtualFile file,
VirtualFile toDir)
Makes a copy of the
file in the toDir folder and returns it. |
static void |
copyDirectory(java.lang.Object requestor,
VirtualFile fromDir,
VirtualFile toDir,
VirtualFileFilter filter)
Copies all files matching the
filter from fromDir to toDir . |
static VirtualFile |
copyFileRelative(java.lang.Object requestor,
VirtualFile file,
VirtualFile toDir,
java.lang.String relativePath)
Deprecated.
obsolete
|
static VirtualFile |
createChildSequent(java.lang.Object requestor,
VirtualFile dir,
java.lang.String prefix,
java.lang.String extension) |
static VirtualFile |
createDirectories(java.lang.String directoryPath) |
static VirtualFile |
createDirectoryIfMissing(java.lang.String directoryPath) |
static VirtualFile |
createDirectoryIfMissing(VirtualFile parent,
java.lang.String relativePath) |
static java.lang.String |
extractFileName(java.lang.String urlOrPath)
Returns a name of the given file.
|
static java.lang.String [] |
filterNames(java.lang.String [] names) |
static VirtualFile |
findFile(java.nio.file.Path file,
boolean refreshIfNeeded) |
static VirtualFile |
findFileByIoFile(java.io.File file,
boolean refreshIfNeeded) |
static VirtualFile |
findFileByURL(java.net.URL url)
Searches for the file specified by given java,net.URL.
|
static VirtualFile |
findRelativeFile(VirtualFile base,
java.lang.String... path) |
static VirtualFile [] |
getChildren(VirtualFile dir) |
static java.util.List<VirtualFile> |
getChildren(VirtualFile dir,
VirtualFileFilter filter) |
static VirtualFile |
getCommonAncestor(java.util.Collection<? extends VirtualFile> files)
Gets the common ancestor for passed files, or
null if the files do not have common ancestors. |
static VirtualFile [] |
getCommonAncestors(VirtualFile [] files)
Gets the array of common ancestors for passed files.
|
static VirtualFile |
getLocalFile(VirtualFile file) |
static java.lang.String |
getNextAvailableName(VirtualFile dir,
java.lang.String prefix,
java.lang.String extension) |
static java.lang.String |
getParentDir(java.lang.String url)
Return a URL of a parent directory of the given file.
|
static java.lang.String |
getPath(VirtualFile src,
VirtualFile dst,
char separatorChar)
Deprecated.
incorrect when
src is a directory; use VfsUtilCore.findRelativePath(VirtualFile, VirtualFile, char) instead |
static java.lang.String |
getReadableUrl(VirtualFile file) |
static java.lang.String |
getUrlForLibraryRoot(java.io.File libraryRoot) |
static VirtualFile |
getUserHomeDir() |
static boolean |
isBadName(java.lang.String name) |
static java.util.List<VirtualFile> |
markDirty(boolean recursive,
boolean reloadChildren,
VirtualFile... files) |
static void |
markDirtyAndRefresh(boolean async,
boolean recursive,
boolean reloadChildren,
java.io.File... files) |
static void |
markDirtyAndRefresh(boolean async,
boolean recursive,
boolean reloadChildren,
VirtualFile... files)
Refreshes the VFS information of the given files from the local file system.
|
static void |
processFileRecursivelyWithoutIgnored(VirtualFile root,
Processor<? super VirtualFile> processor) |
static VirtualFile |
refreshAndFindChild(VirtualFile directory,
java.lang.String name) |
static void |
saveText(VirtualFile file,
java.lang.String text) |
static byte [] |
toByteArray(VirtualFile file,
java.lang.String text) |
static java.lang.String |
toIdeaUrl(java.lang.String url)
Deprecated.
|
static java.net.URI |
toUri(java.io.File file) |
static java.net.URI |
toUri(java.lang.String uri)
uri - may be incorrect (escaping or missed "/" before disk name under windows), may be not fully encoded,
may contains query and fragment
|
static java.net.URI |
toUri(VirtualFile file)
Deprecated.
incorrect, use
toUri(String) if needed (to be removed in IDEA 2019 |
byteStreamSkippingBOM, convertFromUrl, convertToURL, copyFile, copyFile, fileToUrl, findContainingDirectory, findRelativeFile, findRelativePath, fixIDEAUrl, fixURLforIDEA, getCommonAncestor, getRelativeLocation, getRelativePath, getRelativePath, getRootFile, getVirtualFileForJar, hasInvalidFiles, inputStreamSkippingBOM, isAncestor, isAncestor, isBrokenLink, isEqualOrAncestor, isInvalidLink, isUnder, isUnder, iterateChildrenRecursively, iterateChildrenRecursively, loadBytes, loadText, loadText, outputStreamAddingBOM, pathToUrl, processFilesRecursively, toIdeaUrl, toVirtualFileArray, urlToPath, virtualToIoFile, virtualToIoFiles, visitChildrenRecursively, visitChildrenRecursively
public static final long NOTIFICATION_DELAY_MILLIS
public static void saveText(VirtualFile file, java.lang.String text) throws java.io.IOException
java.io.IOException
public static byte [] toByteArray(VirtualFile file, java.lang.String text) throws java.io.IOException
java.io.IOException
public static void copyDirectory(java.lang.Object requestor, VirtualFile fromDir, VirtualFile toDir, VirtualFileFilter filter) throws java.io.IOException
filter
from fromDir
to toDir
.
Symlinks end special files are ignored.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()
fromDir
- the directory to copy fromtoDir
- the directory to copy tofilter
- VirtualFileFilter
java.io.IOException
- if files failed to be copiedpublic static VirtualFile copy(java.lang.Object requestor, VirtualFile file, VirtualFile toDir) throws java.io.IOException
file
in the toDir
folder and returns it.
Handles both files and directories.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()
file
- file or directory to make a copy oftoDir
- directory to make a copy injava.io.IOException
- if file failed to be copiedpublic static VirtualFile [] getCommonAncestors(VirtualFile [] files)
files
- array of filespublic static VirtualFile getCommonAncestor(java.util.Collection<? extends VirtualFile> files)
null
if the files do not have common ancestors.public static VirtualFile findRelativeFile(VirtualFile base, java.lang.String... path)
public static VirtualFile findFileByURL(java.net.URL url)
url
- the URL to find file byVirtualFile
if the file was found, null
otherwisepublic static VirtualFile findFile(java.nio.file.Path file, boolean refreshIfNeeded)
public static VirtualFile findFileByIoFile(java.io.File file, boolean refreshIfNeeded)
public static VirtualFile refreshAndFindChild(VirtualFile directory, java.lang.String name)
public static java.net.URI toUri(java.io.File file)
public static java.net.URI toUri(java.lang.String uri)
public static java.lang.String getUrlForLibraryRoot(java.io.File libraryRoot)
public static java.lang.String getNextAvailableName(VirtualFile dir, java.lang.String prefix, java.lang.String extension)
public static VirtualFile createChildSequent(java.lang.Object requestor, VirtualFile dir, java.lang.String prefix, java.lang.String extension) throws java.io.IOException
java.io.IOException
public static java.lang.String [] filterNames(java.lang.String [] names)
public static boolean isBadName(java.lang.String name)
public static VirtualFile createDirectories(java.lang.String directoryPath) throws java.io.IOException
java.io.IOException
public static VirtualFile createDirectoryIfMissing(VirtualFile parent, java.lang.String relativePath) throws java.io.IOException
java.io.IOException
public static VirtualFile createDirectoryIfMissing(java.lang.String directoryPath) throws java.io.IOException
java.io.IOException
public static java.util.List<VirtualFile> collectChildrenRecursively(VirtualFile root)
public static void processFileRecursivelyWithoutIgnored(VirtualFile root, Processor<? super VirtualFile> processor)
public static java.lang.String getReadableUrl(VirtualFile file)
public static VirtualFile getUserHomeDir()
public static VirtualFile [] getChildren(VirtualFile dir)
public static java.util.List<VirtualFile> getChildren(VirtualFile dir, VirtualFileFilter filter)
public static java.lang.String getParentDir(java.lang.String url)
public static java.lang.String extractFileName(java.lang.String urlOrPath)
public static java.util.List<VirtualFile> markDirty(boolean recursive, boolean reloadChildren, VirtualFile... files)
public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, VirtualFile... files)
VirtualFile.refresh(boolean, boolean)
public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, java.io.File... files)
public static VirtualFile getLocalFile(VirtualFile file)
@Deprecated public static java.lang.String toIdeaUrl(java.lang.String url)
VfsUtilCore.toIdeaUrl(String)
@Deprecated public static VirtualFile copyFileRelative(java.lang.Object requestor, VirtualFile file, VirtualFile toDir, java.lang.String relativePath) throws java.io.IOException
java.io.IOException
@Deprecated public static java.lang.String getPath(VirtualFile src, VirtualFile dst, char separatorChar)
src
is a directory; use VfsUtilCore.findRelativePath(VirtualFile, VirtualFile, char)
instead@Deprecated public static java.net.URI toUri(VirtualFile file)
toUri(String)
if needed (to be removed in IDEA 2019