@@ -67,8 +67,7 @@ class Nextflow {
67
67
return SysEnv . get(name)
68
68
}
69
69
70
- static private fileNamePattern ( FilePatternSplitter splitter , Map opts ) {
71
-
70
+ private static List<Path > fileNamePattern ( FilePatternSplitter splitter , Map opts ) {
72
71
final scheme = splitter. scheme
73
72
final target = scheme ? " $scheme ://$splitter . parent " : splitter. parent
74
73
final folder = toCanonicalPath(target)
@@ -77,15 +76,14 @@ class Nextflow {
77
76
if ( opts == null ) opts = [:]
78
77
if ( ! opts. type ) opts. type = ' file'
79
78
80
- def result = new LinkedList ()
79
+ def result = new LinkedList< Path > ()
81
80
try {
82
81
FileHelper . visitFiles(opts, folder, pattern) { Path it -> result. add(it) }
83
82
}
84
83
catch (NoSuchFileException e) {
85
84
log. debug " No such file or directory: $folder -- Skipping visit"
86
85
}
87
86
return result
88
-
89
87
}
90
88
91
89
static private String str0 (value ) {
@@ -113,11 +111,16 @@ class Nextflow {
113
111
* @param path A file path eventually including a glob pattern e.g. /some/path/file*.txt
114
112
* @return An instance of {@link Path} when a single file is matched or a list of {@link Path}s
115
113
*/
116
- static file ( Map options = null , def filePattern ) {
117
-
114
+ static file (Map options = null , def filePattern ) {
118
115
if ( ! filePattern )
119
- throw new IllegalArgumentException (" Argument of `file` function cannot be ${ filePattern==null?'null':'empty'} " )
116
+ throw new IllegalArgumentException (" Argument of `file()` function cannot be ${ filePattern==null?'null':'empty'} " )
117
+ final result = file0(options, filePattern)
118
+ if ( result instanceof Collection && result. size() != 1 && NF . isSyntaxParserV2() )
119
+ log. warn " The `file()` function was called with a glob pattern that matched a collection of files -- use `files()` instead."
120
+ return result
121
+ }
120
122
123
+ private static file0 ( Map options = null , def filePattern ) {
121
124
final path = filePattern as Path
122
125
final glob = options?. containsKey(' glob' ) ? options. glob as boolean : isGlobAllowed(path)
123
126
if ( ! glob ) {
@@ -140,9 +143,11 @@ class Nextflow {
140
143
return result
141
144
}
142
145
143
- static files ( Map options = null , def path ) {
144
- def result = file(options, path)
145
- return result instanceof List ? result : [result]
146
+ static Collection<Path > files (Map options = null , def filePattern ) {
147
+ if ( ! filePattern )
148
+ throw new IllegalArgumentException (" Argument of `files()` function cannot be ${ filePattern==null?'null':'empty'} " )
149
+ final result = file0(options, filePattern)
150
+ return result instanceof Collection ? result : [result]
146
151
}
147
152
148
153
0 commit comments