1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Fix rootDir problem.

This commit is contained in:
Cedric Beust 2016-02-19 05:15:51 +04:00
parent 2f386a622d
commit 77ca480f57
2 changed files with 21 additions and 14 deletions

View file

@ -42,19 +42,24 @@ sealed class IFileSpec {
val includes = Glob(*spec.toTypedArray())
if (File(filePath).isDirectory) {
val rootDir = if (File(filePath).isAbsolute) Paths.get(filePath)
val rootDir = (if (File(filePath).isAbsolute) Paths.get(filePath)
else if (baseDir != null) Paths.get(baseDir, filePath)
else Paths.get(filePath)
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
val rel = if (baseDir != null && !baseDir.isEmpty()) Paths.get(baseDir).relativize(path)
else path
if (isIncluded(includes, excludes, path)) {
result.add(rel.toFile())
else Paths.get(filePath)).run { normalize() }
if (rootDir.toFile().exists()) {
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
override fun visitFile(p: Path, attrs: BasicFileAttributes): FileVisitResult {
val path = p.normalize()
val rel = rootDir.relativize(path)
if (isIncluded(includes, excludes, path)) {
log(2, " including file " + rel.toFile() + " from rootDir $rootDir")
result.add(rel.toFile())
}
return FileVisitResult.CONTINUE
}
return FileVisitResult.CONTINUE
}
})
})
} else {
throw AssertionError("$rootDir should exist")
}
} else {
if (isIncluded(includes, excludes, Paths.get(filePath))) {
result.add(File(filePath))