public interface VirtualFile extends VirtualFileRef
VirtualFile is an abstraction for file-like objects.
Unlike java.io.File or java.nio.file.Path
that are tied to filesystem-related capabilities, VirtualFile
is designed to be a less-capable object with identity, content reading,
and content hashing.
See also VirtualFileRef
One of the goals of this virtual file (as opposed to a concrete file)
is to abstract from the machine and user specifics.
Previous Zinc's Analysis metadata files
stored file paths using java.io.File.
This impeded them from being shared across machines
without pre- and post-processing them appropriately.
To create a VirtualFile you may use a FileConverter,
such as MappedFileConverter.
MappedFileConverter internally stores the root paths to the working directory,
Coursier's cache, etc..., and it will create a VirtualFile with an id
that looks like ${BASE}/src/main/example/A.scala.
A VirtualFile can also be created with plain Strings
to represent the content, without any "real" files.
IncrementalCompiler.java.
At the top layer of Zinc, we are passing in the source files as a
sequence of VirtualFiles.
The files then gets wrapped by a datatype called AbstractZincFile,
which extends scala.reflect.io.AbstractFile,
which the compiler is able to compile.| Modifier and Type | Method and Description |
|---|---|
long |
contentHash() |
java.io.InputStream |
input() |
id, name, names, of