summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-10-17 10:50:50 +0000
committerBurak Emir <emir@epfl.ch>2006-10-17 10:50:50 +0000
commit7cadf17a7589b825531307cf49bb12a962beb171 (patch)
tree392f9a3c1e55a67b3df857bbf89604835aab2a08 /src
parent2be267a788e24b25011ab1b9593a1b5728a983d8 (diff)
downloadscala-7cadf17a7589b825531307cf49bb12a962beb171.tar.gz
scala-7cadf17a7589b825531307cf49bb12a962beb171.tar.bz2
scala-7cadf17a7589b825531307cf49bb12a962beb171.zip
added handling of zip entries
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/io/SourceReader.scala17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/io/SourceReader.scala b/src/compiler/scala/tools/nsc/io/SourceReader.scala
index eb127be8de..50e9669c2b 100644
--- a/src/compiler/scala/tools/nsc/io/SourceReader.scala
+++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala
@@ -10,9 +10,9 @@
package scala.tools.nsc.io
-import java.io.{File, FileInputStream, IOException}
+import java.io.{File, FileInputStream, InputStream, IOException}
import java.nio.{ByteBuffer, CharBuffer}
-import java.nio.channels.{FileChannel, ReadableByteChannel}
+import java.nio.channels.{FileChannel, ReadableByteChannel, Channels}
import java.nio.charset.{CharsetDecoder, CoderResult}
/** This class implements methods to read and decode source files. */
@@ -42,15 +42,15 @@ class SourceReader(decoder: CharsetDecoder) {
/** Reads the specified file. */
def read(file: File): Array[Char] = {
- val channel: FileChannel = new FileInputStream(file).getChannel()
+ val c = new FileInputStream(file).getChannel
try {
- read(channel)
+ read(c)
} catch {
case e:Exception =>
reportEncodingError(file.toString())
new Array[Char](0)
} finally {
- channel.close()
+ c.close()
}
}
@@ -61,8 +61,11 @@ class SourceReader(decoder: CharsetDecoder) {
*/
def read(file: AbstractFile): Array[Char] = {
file match {
- case p:PlainFile => read(p.file)
- case _ => throw new IOException(file.toString()+" is not a plain file")
+ case p:PlainFile => read(p.file) // bq: (!!!)
+ case z:ZipArchive#FileEntry =>
+ val c = Channels.newChannel(z.getArchive.getInputStream(z.entry))
+ read(c)
+ case _ => throw new IOException(file.toString()+" is neither plain file nor ZipArchive#FileEntry")
}
/*
val decoder: CharsetDecoder = this.decoder.reset();