mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-03 15:15:54 +00:00
Add method to list with excludes
This commit is contained in:
1 parent
f568a43170
commit
5cbe17973b
2 files changed
+60
-5
No files matched your search
@@ -1199,9 +1199,22 @@ public final class FilePath implements Serializable {
|
||||
* can be empty but always non-null.
|
||||
*/
|
||||
public FilePath[] list(final String includes) throws IOException, InterruptedException {
|
||||
return list(includes, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* List up files in this directory that matches the given Ant-style filter.
|
||||
*
|
||||
* @param includes
|
||||
* @param excludes
|
||||
* See {@link FileSet} for the syntax. String like "foo/*.zip" or "foo/**/*.xml"
|
||||
* @return
|
||||
* can be empty but always non-null.
|
||||
*/
|
||||
public FilePath[] list(final String includes, final String excludes) throws IOException, InterruptedException {
|
||||
return act(new FileCallable<FilePath[]>() {
|
||||
public FilePath[] invoke(File f, VirtualChannel channel) throws IOException {
|
||||
String[] files = glob(f,includes);
|
||||
String[] files = glob(f,includes,excludes);
|
||||
|
||||
FilePath[] r = new FilePath[files.length];
|
||||
for( int i=0; i<r.length; i++ )
|
||||
@@ -1218,10 +1231,10 @@ public final class FilePath implements Serializable {
|
||||
* @return
|
||||
* A set of relative file names from the base directory.
|
||||
*/
|
||||
private static String[] glob(File dir, String includes) throws IOException {
|
||||
private static String[] glob(File dir, String includes, String excludes) throws IOException {
|
||||
if(isAbsolute(includes))
|
||||
throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
|
||||
FileSet fs = Util.createFileSet(dir,includes);
|
||||
FileSet fs = Util.createFileSet(dir,includes,excludes);
|
||||
DirectoryScanner ds = fs.getDirectoryScanner(new Project());
|
||||
String[] files = ds.getIncludedFiles();
|
||||
return files;
|
||||
|
||||
Reference in new issue
Block a user