blob: 6609b2956188ae7d84e232dce7944be9605fa4cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* __ *\
** ________ ___ / / ___ __ ____ Scala.js tools **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2014, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
** /____/\___/_/ |_/____/_/ | |__/ /____/ **
** |/____/ **
\* */
package scala.scalajs.tools.classpath.builder
import scala.scalajs.tools.io._
import scala.scalajs.tools.jsdep.JSDependencyManifest
import scala.collection.mutable
trait DirTraverser extends ClasspathContentHandler with FileSystem {
/** Traverses elements, returns a version string */
protected def traverseDir(dir: File): String = {
val versions = mutable.SortedSet.empty[String]
recurseDir(dir, "", versions)
// Construct version
CacheUtils.joinVersions(versions.toSeq: _*)
}
/** Recursively adds the Scala.js classpath entries in a directory */
private def recurseDir(dir: File, dirPath: String,
versions: mutable.SortedSet[String]): Unit = {
val files = listFiles(dir)
for (file <- files) {
val name = getName(file)
if (isDirectory(file)) {
recurseDir(file, dirPath + name + "/", versions)
} else {
val path = dirPath + name
path match {
case JSDependencyManifest.ManifestFileName =>
versions += getGlobalVersion(file)
val reader = toReader(file)
try handleDepManifest(JSDependencyManifest.read(reader))
finally reader.close()
case _ if isJSFile(file) =>
versions += getGlobalVersion(file)
handleJS(toJSFile(file))
case _ if isIRFile(file) =>
versions += getGlobalVersion(file)
handleIR(path, toIRFile(file))
case _ => // ignore other files
}
}
}
}
}
|