AdGuard v3.6.45版本的 MD5 值为:ce30a13dcef92cf942973fffcc6d20fb
以下内容为反编译后的 RenameUtil.java 源代码,内容仅作参考
package ch.qos.logback.core.rolling.helper;
import ch.qos.logback.core.rolling.RollingFileAppender;
import ch.qos.logback.core.rolling.RolloverFailure;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.util.EnvUtil;
import ch.qos.logback.core.util.FileUtil;
import java.io.File;
public class RenameUtil extends ContextAwareBase {
static String RENAMING_ERROR_URL = "http://logback.qos.ch/codes.html#renamingError";
Boolean areOnDifferentVolumes(File file, File file2) {
if (EnvUtil.isJDK7OrHigher()) {
File parentFile = file2.getAbsoluteFile().getParentFile();
if (parentFile == null) {
addWarn("Parent of target file [" + file2 + "] is null");
return null;
} else if (parentFile.exists()) {
try {
return Boolean.valueOf(!FileStoreUtil.areOnSameFileStore(file, parentFile));
} catch (RolloverFailure e) {
addWarn("Error while checking file store equality", e);
return null;
}
} else {
addWarn("Parent of target file [" + file2 + "] does not exist");
return null;
}
}
return Boolean.FALSE;
}
void createMissingTargetDirsIfNecessary(File file) {
if (FileUtil.createMissingParentDirectories(file)) {
return;
}
throw new RolloverFailure("Failed to create parent directories for [" + file.getAbsolutePath() + "]");
}
public void rename(String str, String str2) {
if (str.equals(str2)) {
addWarn("Source and target files are the same [" + str + "]. Skipping.");
return;
}
File file = new File(str);
if (!file.exists()) {
throw new RolloverFailure("File [" + str + "] does not exist.");
}
File file2 = new File(str2);
createMissingTargetDirsIfNecessary(file2);
addInfo("Renaming file [" + file + "] to [" + file2 + "]");
if (file.renameTo(file2)) {
return;
}
addWarn("Failed to rename file [" + file + "] as [" + file2 + "].");
if (Boolean.TRUE.equals(areOnDifferentVolumes(file, file2))) {
addWarn("Detected different file systems for source [" + str + "] and target [" + str2 + "]. Attempting rename by copying.");
renameByCopying(str, str2);
return;
}
addWarn("Please consider leaving the [file] option of " + RollingFileAppender.class.getSimpleName() + " empty.");
StringBuilder sb = new StringBuilder("See also ");
sb.append(RENAMING_ERROR_URL);
addWarn(sb.toString());
}
public void renameByCopying(String str, String str2) {
new FileUtil(getContext()).copy(str, str2);
if (new File(str).delete()) {
return;
}
addWarn("Could not delete ".concat(String.valueOf(str)));
}
public String toString() {
return "c.q.l.co.rolling.helper.RenameUtil";
}
}