Replace guava deleteRecursively with internal version for guava compat

This commit is contained in:
Mumfrey committed 2021-12-04 13:02:06 +00:00
1 parent ad1d110a63
commit 45856b4028
4 files changed
+43 -7

No files matched your search

+2 -1
View File
@@ -221,7 +221,8 @@ javadoc {
classpath += sourceSets.legacy.output
source sourceSets.ap.allJava
exclude {
it.relativePath.file && it.relativePath.pathString =~ 'tools' && !(it.name =~ /SuppressedBy|package-info/) }
it.relativePath.file && it.relativePath.pathString =~ 'tools' && !(it.name =~ /SuppressedBy|package-info/)
}
options {
docTitle 'Welcome to the Mixin Javadoc'
overview 'docs/javadoc/overview.html'
@@ -45,8 +45,6 @@ import org.spongepowered.asm.service.MixinService;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import com.google.common.io.MoreFiles;
import com.google.common.io.RecursiveDeleteOption;
/**
* Wrapper for FernFlower to support runtime-decompilation of post-mixin classes
@@ -73,7 +71,7 @@ public class RuntimeDecompiler extends IFernflowerLogger implements IDecompiler,
this.outputPath = outputPath;
if (this.outputPath.exists()) {
try {
MoreFiles.deleteRecursively(this.outputPath.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
org.spongepowered.asm.util.Files.deleteRecursively(this.outputPath);
} catch (IOException ex) {
this.logger.debug("Error cleaning output directory: {}", ex.getMessage());
}
@@ -44,8 +44,6 @@ import org.spongepowered.asm.util.perf.Profiler;
import org.spongepowered.asm.util.perf.Profiler.Section;
import com.google.common.io.Files;
import com.google.common.io.MoreFiles;
import com.google.common.io.RecursiveDeleteOption;
/**
* Debug exporter
@@ -76,7 +74,7 @@ public class ExtensionClassExporter implements IExtension {
this.decompiler = this.initDecompiler(env, new File(Constants.DEBUG_OUTPUT_DIR, ExtensionClassExporter.EXPORT_JAVA_DIR));
try {
MoreFiles.deleteRecursively(this.classExportDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
org.spongepowered.asm.util.Files.deleteRecursively(this.classExportDir);
} catch (IOException ex) {
ExtensionClassExporter.logger.debug("Error cleaning class output directory: {}", ex.getMessage());
}
@@ -25,6 +25,7 @@
package org.spongepowered.asm.util;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -75,4 +76,42 @@ public final class Files {
return new File(uri);
}
/**
* Recursively delete a directory. Does not support symlinks but this is
* mainly used by mixin internals which only write files and normal
* directories so it should be fine
*
* @param dir Root directory to delete
* @throws IOException Security errors and any other IO errors encountered
* are raised as IOExceptions
*/
public static void deleteRecursively(File dir) throws IOException {
if (dir == null || !dir.isDirectory()) {
return;
}
try {
File[] files = dir.listFiles();
if (files == null) {
throw new IOException("Error enumerating directory during recursive delete operation: " + dir.getAbsolutePath());
}
for (File child : files) {
if (child.isDirectory()) {
Files.deleteRecursively(child);
} else if (child.isFile()) {
if (!child.delete()) {
throw new IOException("Error deleting file during recursive delete operation: " + child.getAbsolutePath());
}
}
}
if (!dir.delete()) {
throw new IOException("Error deleting directory during recursive delete operation: " + dir.getAbsolutePath());
}
} catch (SecurityException ex) {
throw new IOException("Security error during recursive delete operation", ex);
}
}
}