Skip to content

Commit

Permalink
Convert windows styled path to unix style
Browse files Browse the repository at this point in the history
  • Loading branch information
gtn1024 committed May 25, 2023
1 parent 1436854 commit 828059a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/src/main/kotlin/com/bytelegend/utils/CheckLicenses.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.bytelegend.utils

import org.apache.commons.io.FilenameUtils
import org.springframework.util.AntPathMatcher
import java.io.File
import java.io.IOException
Expand Down Expand Up @@ -53,18 +54,20 @@ internal val INCLUDED_PATHS = listOf(
)
internal val MATCHER = AntPathMatcher()

internal fun Path.unixStyle(): String = FilenameUtils.separatorsToUnix(this.toString())

internal fun Path.isIgnoredPath(): Boolean = IGNORED_PATHS.any {
// Remove leading "./"
require(!this.isAbsolute) { "$this must be relative!" }
if (this.toString() == ".") {
if (this.unixStyle() == ".") {
return false
}
MATCHER.match(it, this.toString().substring(2))
MATCHER.match(it, this.unixStyle().substring(2))
}

internal fun Path.isIncludedPath() = INCLUDED_PATHS.any {
// Remove leading "./"
MATCHER.match(it, this.toString().substring(2))
MATCHER.match(it, this.unixStyle().substring(2))
}

internal fun File.parseLicense() = when {
Expand Down
1 change: 1 addition & 0 deletions utils/utils.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {
implementation(libs("commonmark"))
implementation(libs("commonmark-ext-task-list-items"))
implementation(libs("animated-gif-lib-for-java"))
implementation(libs("commons-io"))

testImplementation(libs("junit-jupiter-api"))
testImplementation(libs("junit-jupiter-engine"))
Expand Down

0 comments on commit 828059a

Please sign in to comment.