diff options
author | Lex Spoon <lex@lexspoon.org> | 2008-05-05 14:09:00 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2008-05-05 14:09:00 +0000 |
commit | 06efde1f28ec6ad3f0008e3aaf08f292f0ae452f (patch) | |
tree | d1c81a7504a4ada89ff193282d638d3bd79a5c02 /src/compiler/scala/tools/nsc/io/AbstractFile.scala | |
parent | 72615dc18e18dabd211a684a5b395daf3373dfed (diff) | |
download | scala-06efde1f28ec6ad3f0008e3aaf08f292f0ae452f.tar.gz scala-06efde1f28ec6ad3f0008e3aaf08f292f0ae452f.tar.bz2 scala-06efde1f28ec6ad3f0008e3aaf08f292f0ae452f.zip |
The interpreter no longer generates class files...
The interpreter no longer generates class files to disk. It instead uses
an in-memory virtual directory.
Diffstat (limited to 'src/compiler/scala/tools/nsc/io/AbstractFile.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/AbstractFile.scala | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala index 36c17ef6c9..26782dfeb9 100644 --- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala +++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala @@ -7,7 +7,7 @@ package scala.tools.nsc.io -import java.io.{File, IOException, InputStream} +import java.io.{File, FileOutputStream, IOException, InputStream, OutputStream} import java.net.URL import scala.collection.mutable.ArrayBuffer @@ -117,6 +117,9 @@ abstract class AbstractFile extends AnyRef with Iterable[AbstractFile] { /** returns an input stream so the file can be read */ def input: InputStream + /** Returns an output stream for writing the file */ + def output: OutputStream + /** size of this file if it is a concrete file. */ def size: Option[Int] = None @@ -187,6 +190,38 @@ abstract class AbstractFile extends AnyRef with Iterable[AbstractFile] { file } + /** + * Get the file in this directory with the given name, + * creating an empty file if it does not already existing. + */ + def fileNamed(name: String): AbstractFile = { + assert(isDirectory) + val existing = lookupName(name, false) + if (existing == null) { + val newFile = new File(file, name) + newFile.createNewFile() + new PlainFile(newFile) + } else { + existing + } + } + + /** + * Get the subdirectory with a given name, creating it if it + * does not already exist. + */ + def subdirectoryNamed(name: String): AbstractFile = { + assert (isDirectory) + val existing = lookupName(name, true) + if (existing == null) { + val dir = new File(file, name) + dir.mkdir() + new PlainFile(dir) + } else { + existing + } + } + /** Returns the path of this abstract file. */ override def toString() = path |