mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Fix empty directory FileSpec.
This commit is contained in:
parent
460160f48e
commit
71e9da4437
1 changed files with 4 additions and 2 deletions
|
@ -42,14 +42,16 @@ sealed class IFileSpec {
|
||||||
val includes = Glob(*spec.toTypedArray())
|
val includes = Glob(*spec.toTypedArray())
|
||||||
|
|
||||||
if (File(filePath).isDirectory) {
|
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 if (baseDir != null) Paths.get(baseDir, filePath)
|
||||||
else Paths.get(filePath)).run { normalize() }
|
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()) {
|
if (rootDir.toFile().exists()) {
|
||||||
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
|
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
|
||||||
override fun visitFile(p: Path, attrs: BasicFileAttributes): FileVisitResult {
|
override fun visitFile(p: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||||
val path = p.normalize()
|
val path = p.normalize()
|
||||||
val rel = rootDir.relativize(path)
|
val rel = orgRootDir.relativize(path)
|
||||||
if (isIncluded(includes, excludes, path)) {
|
if (isIncluded(includes, excludes, path)) {
|
||||||
log(2, " including file " + rel.toFile() + " from rootDir $rootDir")
|
log(2, " including file " + rel.toFile() + " from rootDir $rootDir")
|
||||||
result.add(rel.toFile())
|
result.add(rel.toFile())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue