summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2009-05-19 17:42:52 +0000
committerMiles Sabin <miles@milessabin.com>2009-05-19 17:42:52 +0000
commit6d20b470c5b43c17a885615e1761190fab366096 (patch)
tree8bc57278da0cb98d8c9200ba0dfb079b19f18c63 /src/compiler
parentb3ce4c4f7d2e2016d7b71bea2df7aa6dc75bc3d5 (diff)
downloadscala-6d20b470c5b43c17a885615e1761190fab366096.tar.gz
scala-6d20b470c5b43c17a885615e1761190fab366096.tar.bz2
scala-6d20b470c5b43c17a885615e1761190fab366096.zip
Added support for AbstractFile subclasses other...
Added support for AbstractFile subclasses other than PlainFile and ZipArchive#FileEntry.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/io/SourceReader.scala29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/io/SourceReader.scala b/src/compiler/scala/tools/nsc/io/SourceReader.scala
index 0f157aa71e..15ccee983f 100644
--- a/src/compiler/scala/tools/nsc/io/SourceReader.scala
+++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala
@@ -67,20 +67,16 @@ class SourceReader(decoder: CharsetDecoder, reporter: Reporter) {
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 b = ByteBuffer.wrap(file.toByteArray)
+ try {
+ read(b)
+ } catch {
+ case e:Exception =>
+ if (true) e.printStackTrace
+ reportEncodingError(file.toString())
+ new Array[Char](0)
+ }
}
- /*
- val decoder: CharsetDecoder = this.decoder.reset();
- val bytes: ByteBuffer = ByteBuffer.wrap(file.read);
- val chars: CharBuffer = this.chars; chars.clear();
- try {
- terminate(flush(decoder, decode(decoder, bytes, chars, true)));
- } catch {
- case e:Exception =>
- reportEncodingError(file.toString())
- new Array[Char](0)
- }
- */
}
/** Reads the specified byte channel. */
@@ -97,6 +93,13 @@ class SourceReader(decoder: CharsetDecoder, reporter: Reporter) {
terminate(flush(decoder, chars))
}
+ /** Reads the specified byte buffer. */
+ protected def read(bytes: ByteBuffer): Array[Char] = {
+ val decoder: CharsetDecoder = this.decoder.reset()
+ val chars: CharBuffer = this.chars; chars.clear()
+ terminate(flush(decoder, decode(decoder, bytes, chars, true)))
+ }
+
//########################################################################
// Private Methods