public abstract class VirtualFile extends Object implements Comparable<VirtualFile>, Serializable
File, FilePath, or other items such as network resources or ZIP entries.
Assumed to be read-only and makes very limited assumptions, just enough to display content and traverse directories.
To obtain a VirtualFile representation for an existing file, use forFile(File) or FilePath.toVirtualFile()
FilePath abstracts away Files on machines that are connected over Channel, whereas
VirtualFile makes no assumption about where the actual files are, or whether there really exists
Files somewhere. This makes VirtualFile more abstract.
DirectoryBrowserSupport,
FilePath,
Serialized Form| Constructor and Description |
|---|
VirtualFile() |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
canRead()
Checks whether this file can be read.
|
abstract VirtualFile |
child(String name)
Obtains a child file.
|
int |
compareTo(VirtualFile o)
Does case-insensitive comparison.
|
boolean |
equals(Object obj)
Compares according to
toURI(). |
abstract boolean |
exists()
Checks whether this file exists.
|
static VirtualFile |
forFile(File f)
Creates a virtual file wrapper for a local file.
|
static VirtualFile |
forFilePath(FilePath f)
Creates a virtual file wrapper for a remotable file.
|
abstract String |
getName()
Gets the base name, meaning just the last portion of the path name without any
directories.
|
abstract VirtualFile |
getParent()
Gets the parent file.
|
int |
hashCode()
Hashes according to
toURI(). |
abstract boolean |
isDirectory()
Checks whether this file exists and is a directory.
|
abstract boolean |
isFile()
Checks whether this file exists and is a plain file.
|
abstract long |
lastModified()
Gets the file timestamp.
|
abstract long |
length()
Gets the file length.
|
abstract VirtualFile[] |
list()
Lists children of this directory.
|
abstract String[] |
list(String glob)
Lists recursive files of this directory with pattern matching.
|
abstract InputStream |
open()
Opens an input stream on the file so its contents can be read.
|
<V> V |
run(hudson.remoting.Callable<V,IOException> callable)
Does some calculations in batch.
|
String |
toString()
Displays
toURI(). |
abstract URI |
toURI()
Gets a URI.
|
@Nonnull public abstract String getName()
public abstract URI toURI()
public abstract VirtualFile getParent()
public abstract boolean isDirectory()
throws IOException
IOException - in case checking status failedpublic abstract boolean isFile()
throws IOException
IOException - in case checking status failedpublic abstract boolean exists()
throws IOException
IOException - in case checking status failed@Nonnull public abstract VirtualFile[] list() throws IOException
IOException - if this directory exists but listing was not possible for some other reason@Nonnull public abstract String[] list(String glob) throws IOException
glob - an Ant-style globIOException - if this is not a directory, or listing was not possible for some other reason@Nonnull public abstract VirtualFile child(@Nonnull String name)
name - a relative path, possibly including / (but not ..)public abstract long length()
throws IOException
IOException - if checking the length failedpublic abstract long lastModified()
throws IOException
IOException - if checking the timestamp failedpublic abstract boolean canRead()
throws IOException
IOException - if checking status failedpublic abstract InputStream open() throws IOException
IOException - if it could not be openedpublic final int compareTo(VirtualFile o)
compareTo in interface Comparable<VirtualFile>public final int hashCode()
toURI().
public <V> V run(hudson.remoting.Callable<V,IOException> callable) throws IOException
V - a value typeT - the exception typecallable - something to run all at once (only helpful if any mentioned files are on the same system)IOException - if remote communication failedpublic static VirtualFile forFile(File f)
f - a disk file (need not exist)public static VirtualFile forFilePath(FilePath f)
f - a local or remote file (need not exist)Copyright © 2019. All rights reserved.