@ -15,13 +15,9 @@
* /
* /
package ro.fortsoft.pf4j.util ;
package ro.fortsoft.pf4j.util ;
import java.io.BufferedReader ;
import java.io.* ;
import java.io.BufferedWriter ;
import java.nio.file.Files ;
import java.io.File ;
import java.nio.file.Path ;
import java.io.FileFilter ;
import java.io.FileReader ;
import java.io.FileWriter ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Collection ;
import java.util.List ;
import java.util.List ;
@ -96,27 +92,27 @@ public class FileUtils {
return success ;
return success ;
}
}
public static List < File > getJars ( File folder ) {
public static List < File > getJars ( Path folder ) {
List < File > bucket = new ArrayList < > ( ) ;
List < File > bucket = new ArrayList < > ( ) ;
getJars ( bucket , folder ) ;
getJars ( bucket , folder ) ;
return bucket ;
return bucket ;
}
}
private static void getJars ( List < File > bucket , File folder ) {
private static void getJars ( final List < File > bucket , Path folder ) {
FileFilter jarFilter = new JarFileFilter ( ) ;
FileFilter jarFilter = new JarFileFilter ( ) ;
FileFilter directoryFilter = new DirectoryFileFilter ( ) ;
FileFilter directoryFilter = new DirectoryFileFilter ( ) ;
if ( folder . exists ( ) & & folder . isDirectory ( ) & & folder . isAbsolute ( ) ) {
if ( Files . exists ( folder ) & & Files . isDirectory ( folder ) ) {
File [ ] jars = folder . listFiles ( jarFilter ) ;
File [ ] jars = folder . toFile ( ) . listFiles ( jarFilter ) ;
for ( int i = 0 ; ( jars ! = null ) & & ( i < jars . length ) ; + + i ) {
for ( int i = 0 ; ( jars ! = null ) & & ( i < jars . length ) ; + + i ) {
bucket . add ( jars [ i ] ) ;
bucket . add ( jars [ i ] ) ;
}
}
File [ ] directories = folder . listFiles ( directoryFilter ) ;
File [ ] directories = folder . toFile ( ) . listFiles ( directoryFilter ) ;
for ( int i = 0 ; ( directories ! = null ) & & ( i < directories . length ) ; + + i ) {
for ( int i = 0 ; ( directories ! = null ) & & ( i < directories . length ) ; + + i ) {
File directory = directories [ i ] ;
File directory = directories [ i ] ;
getJars ( bucket , directory ) ;
getJars ( bucket , directory . toPath ( ) ) ;
}
}
}
}
}
}