Skip to content

Commit

Permalink
Merge pull request #29 from neilcsmith-net/gh28
Browse files Browse the repository at this point in the history
Fix InvalidPathException issue on Windows in FileUtils::findDirs
  • Loading branch information
neilcsmith-net committed May 31, 2023
2 parents 2c124bf + 2fa83e1 commit 7110ddd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ on:
types: [opened, synchronize, unlocked]

jobs:
build:

runs-on: ubuntu-latest
linux-build:
name: Build and test on ${{ matrix.os }}, JDK ${{ matrix.java }}
strategy:
matrix:
java: [ '11', '17' ]
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/org/apache/netbeans/nbpackage/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,15 @@ public static List<Path> find(Path searchDir, String pattern) throws IOException
/**
* Find the directories in the given search directory that contains files
* that match the given glob patterns. This might include the search
* directory itself. eg. to find NetBeans or a RCP application in a search
* directory you might pass <code>"bin/*", "etc/*.conf"</code>.
* directory itself. eg. to find the root directory of NetBeans or a RCP
* application in a search directory you might pass
* <code>"bin/*", "etc/*.conf"</code>.
* <p>
* All patterns should use <code>/</code> as the separator character, and
* should not use <code>**</code>, the boundary crossing wildcard. The
* search depth parameter controls the maximum depth of any potential root
* directory. The maximum path depth of all patterns is used to control how
* deep the search is <em>within</em> each potential root.
*
* @param searchDir search directory
* @param searchDepth search depth
Expand All @@ -243,8 +250,8 @@ public static List<Path> findDirs(Path searchDir, int searchDepth, String... pat
.map(p -> FileSystems.getDefault().getPathMatcher("glob:" + p))
.collect(Collectors.toList());
var intDepth = Stream.of(patterns)
.map(Path::of)
.mapToInt(Path::getNameCount)
.map(p -> p.split("/"))
.mapToInt(ps -> ps.length)
.max().orElse(1);
try (var stream = Files.find(searchDir, searchDepth, (intPath, attr) -> {
return matchers.stream().map(m -> {
Expand Down

0 comments on commit 7110ddd

Please sign in to comment.