diff options
author | paltherr <paltherr@epfl.ch> | 2004-03-21 04:30:05 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-03-21 04:30:05 +0000 |
commit | 92763237f37452a9325e94f63ad5b7faa4ac04ca (patch) | |
tree | 6771d2db226a4ec24c5f68a865b528b15975627b | |
parent | 45028dc737cd1628c45db0fd00c666689876f706 (diff) | |
download | scala-92763237f37452a9325e94f63ad5b7faa4ac04ca.tar.gz scala-92763237f37452a9325e94f63ad5b7faa4ac04ca.tar.bz2 scala-92763237f37452a9325e94f63ad5b7faa4ac04ca.zip |
- Added VirtualFile and ByteArrayFile
-rw-r--r-- | sources/scala/tools/util/AbstractFile.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/sources/scala/tools/util/AbstractFile.java b/sources/scala/tools/util/AbstractFile.java index 409c695dff..6bd15e809a 100644 --- a/sources/scala/tools/util/AbstractFile.java +++ b/sources/scala/tools/util/AbstractFile.java @@ -587,3 +587,78 @@ final class JarArchive extends AbstractFile { } } } + + +public class VirtualFile extends AbstractFile { + + /** The file name */ + private final String name; + + /** The file path */ + private final String path; + + public VirtualFile(String name) { + this(name, name); + } + + public VirtualFile(String name, String path) { + this.name = name; + this.path = path; + } + + public String getName() { + return name; + } + + public String getPath() { + return path; + } + + public boolean exists() { + return false; + } + + public boolean isDirectory() { + return false; + } + + public long lastModified() { + return Long.MIN_VALUE; + } + + public byte[] read() { + return new byte[0]; + } + + public String[] list() { + return new String[0]; + } + + public AbstractFile open(String name) { + return null; + } + +} + +public class ByteArrayFile extends VirtualFile { + + private final byte[] bytes; + + public ByteArrayFile(String name, byte[] bytes) { + this(name, name, bytes); + } + + public ByteArrayFile(String name, String path, byte[] bytes) { + super(name, path); + this.bytes = bytes; + } + + public boolean exists() { + return true; + } + + public byte[] read() { + return bytes; + } + +} |