feat(plugins): allow to use .zip as plugin artifact (with jars inside)
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -78,6 +79,22 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Path> listFiles(Path dir) {
|
||||
try (Stream<Path> files = Files.list(dir)) {
|
||||
return files.collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
throw new JadxRuntimeException("Failed to list files in directory: " + dir, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Path> listFiles(Path dir, Predicate<? super Path> filter) {
|
||||
try (Stream<Path> files = Files.list(dir)) {
|
||||
return files.filter(filter).collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
throw new JadxRuntimeException("Failed to list files in directory: " + dir, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Path> expandDirs(List<Path> paths) {
|
||||
List<Path> files = new ArrayList<>(paths.size());
|
||||
for (Path path : paths) {
|
||||
@@ -148,6 +165,10 @@ public class FileUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void deleteDir(Path dir) {
|
||||
deleteDir(dir, false);
|
||||
}
|
||||
|
||||
public static void deleteDirIfExists(Path dir) {
|
||||
if (Files.exists(dir)) {
|
||||
try {
|
||||
@@ -158,10 +179,6 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteDir(Path dir) {
|
||||
deleteDir(dir, false);
|
||||
}
|
||||
|
||||
private static void deleteDir(Path dir, boolean keepRootDir) {
|
||||
try {
|
||||
List<Path> files = new ArrayList<>();
|
||||
@@ -424,6 +441,11 @@ public class FileUtils {
|
||||
return fileName.substring(0, extEndIndex);
|
||||
}
|
||||
|
||||
public static boolean hasExtension(Path path, String extension) {
|
||||
String fileName = path.getFileName().toString();
|
||||
return fileName.toLowerCase().endsWith(extension);
|
||||
}
|
||||
|
||||
public static File toFile(String path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user