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

Fix empty directory FileSpec.

This commit is contained in:
Cedric Beust 2016-02-20 02:09:20 +04:00
parent 460160f48e
commit 71e9da4437

View file

@ -42,14 +42,16 @@ sealed class IFileSpec {
val includes = Glob(*spec.toTypedArray())
if (File(filePath).isDirectory) {
val rootDir = (if (File(filePath).isAbsolute) Paths.get(filePath)
val orgRootDir = (if (File(filePath).isAbsolute) Paths.get(filePath)
else if (baseDir != null) Paths.get(baseDir, filePath)
else Paths.get(filePath)).run { normalize() }
// Paths.get(".").normalize() returns an empty string, which is not a valid file :-(
val rootDir = if (orgRootDir.toFile().path.isEmpty()) Paths.get("./") else orgRootDir
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)
val rel = orgRootDir.relativize(path)
if (isIncluded(includes, excludes, path)) {
log(2, " including file " + rel.toFile() + " from rootDir $rootDir")
result.add(rel.toFile())