diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-12 07:25:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-12 07:25:47 +0000 |
commit | bf1da638ccae6fa494570441676193edb99ee882 (patch) | |
tree | 42524bae17569c1f70b0dc43d78aaf036d5a3d5d /src | |
parent | 692f32f66be2bba2cb860281ea2b63479fdb3a85 (diff) | |
download | scala-bf1da638ccae6fa494570441676193edb99ee882.tar.gz scala-bf1da638ccae6fa494570441676193edb99ee882.tar.bz2 scala-bf1da638ccae6fa494570441676193edb99ee882.zip |
Reverting a little of that last patch, no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/AbstractFile.scala | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala index bafb78e9f2..4b196877a3 100644 --- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala +++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala @@ -148,7 +148,19 @@ abstract class AbstractFile extends AnyRef with Iterable[AbstractFile] { /** Returns contents of file (if applicable) in a byte array. */ @throws(classOf[IOException]) - def toByteArray: Array[Byte] = Streamable.toByteArray(input, sizeOption getOrElse -1) + def toByteArray: Array[Byte] = { + val in = input + var rest = sizeOption.get + val arr = new Array[Byte](rest) + while (rest > 0) { + val res = in.read(arr, arr.length - rest, rest) + if (res == -1) + throw new IOException("read error") + rest -= res + } + in.close() + arr + } /** Returns all abstract subfiles of this abstract directory. */ def iterator: Iterator[AbstractFile] |