summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-07-02 20:50:29 +0000
committerPaul Phillips <paulp@improving.org>2010-07-02 20:50:29 +0000
commit322e856f132c4ee8ac651848a041b693f830371b (patch)
treec49bf1cb826cad39633fdb558244cc9427a59e32
parent78b419c329996995ba26b269583f8b375e3bfe8c (diff)
downloadscala-322e856f132c4ee8ac651848a041b693f830371b.tar.gz
scala-322e856f132c4ee8ac651848a041b693f830371b.tar.bz2
scala-322e856f132c4ee8ac651848a041b693f830371b.zip
Routed all places in trunk which look for jar f...
Routed all places in trunk which look for jar files through the same function, and then changed the default behavior to recognize jars even if they don't have a *.jar extension by squinting at the first few bytes of the file. Closes #3000 (THE AMAZING TICKET 3000!), review by phaller.
-rw-r--r--src/compiler/scala/tools/nsc/io/Path.scala7
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala
index afef38be3c..4373cc64a5 100644
--- a/src/compiler/scala/tools/nsc/io/Path.scala
+++ b/src/compiler/scala/tools/nsc/io/Path.scala
@@ -26,15 +26,14 @@ import scala.util.Random.alphanumeric
* @since 2.8
*/
-object Path
-{
+object Path {
private val ZipMagicNumber = List[Byte](80, 75, 3, 4)
+ private def magicNumberIsZip(f: Path) = f.isFile && (f.toFile.bytes().take(4).toList == ZipMagicNumber)
/** If examineFile is true, it will look at the first four bytes of the file
* and see if the magic number indicates it may be a jar or zip.
*/
- private def magicNumberIsZip(f: Path) = f.isFile && (f.toFile.bytes().take(4).toList == ZipMagicNumber)
- def isJarOrZip(f: Path): Boolean = isJarOrZip(f, false)
+ def isJarOrZip(f: Path): Boolean = isJarOrZip(f, true)
def isJarOrZip(f: Path, examineFile: Boolean): Boolean =
f.hasExtension("zip", "jar") || (examineFile && magicNumberIsZip(f))
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 1b7e208334..49bbb12a9a 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -133,7 +133,7 @@ object Plugin {
val alljars = (jars ::: (for {
dir <- dirs if dir.isDirectory
entry <- dir.toDirectory.files.toList sortBy (_.name)
- if entry.extension == "jar"
+ if Path.isJarOrZip(entry)
pdesc <- loadDescription(entry)
if !(ignoring contains pdesc.name)
} yield entry)).distinct