Skip to content

Commit 8bd24fa

Browse files
committed
Change return type of listFiles() from Path[] to List<Path>
Signed-off-by: Ben Sherman <[email protected]>
1 parent 064ef34 commit 8bd24fa

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

modules/nf-commons/src/main/nextflow/extension/FilesEx.groovy

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ class FilesEx {
625625
* @param self The folder to list
626626
* @return A list of strings or {@code null} if the path is not a folder
627627
*/
628-
static String[] list(Path self) {
629-
listFiles(self).collect { getName(it) } as String[]
628+
static List<String> list(Path self) {
629+
return listFiles(self).collect { getName(it) }
630630
}
631631

632632
/**
@@ -636,12 +636,13 @@ class FilesEx {
636636
* @param self The folder to list
637637
* @return A list of {@code Path} or {@code null} if the path is not a folder
638638
*/
639-
static Path[] listFiles(Path self, @ClosureParams(value = FromString.class, options = ["java.nio.file.Path", "java.nio.file.Path,java.nio.file.attribute.BasicFileAttributes"]) Closure<Boolean> filter=null) {
639+
static List<Path> listFiles(Path self, @ClosureParams(value = FromString.class, options = ["java.nio.file.Path", "java.nio.file.Path,java.nio.file.attribute.BasicFileAttributes"]) Closure<Boolean> filter=null) {
640640

641641
if( !self.isDirectory() )
642642
return null
643643

644-
def result = []
644+
final result = []
645+
645646
Files.walkFileTree(self, new SimpleFileVisitor<Path>() {
646647

647648
FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
@@ -651,19 +652,17 @@ class FilesEx {
651652
}
652653

653654
FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
654-
if( self == dir )
655+
if( self == dir ) {
655656
FileVisitResult.CONTINUE
656-
657+
}
657658
else {
658659
result.add(dir)
659660
FileVisitResult.SKIP_SUBTREE
660661
}
661662
}
662-
663663
} )
664664

665-
return result as Path[]
666-
665+
return result
667666
}
668667

669668
@CompileStatic

0 commit comments

Comments
 (0)