no message
This commit is contained in:
@@ -13,7 +13,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
//Основной объект визуализатора.
|
||||
public abstract class MainModule_<D extends VisualiserDatabase> {
|
||||
public static MainModule_ object = null; //текущий экземпляр
|
||||
public static MainModule_ object = null; //текущий экземпляр. всегда один.
|
||||
//--
|
||||
D db;
|
||||
Class<D> db_class;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package Common.Utils;
|
||||
import Common.Visual.UI_;
|
||||
import _VisualDVM.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -16,7 +15,7 @@ public interface Loggable {
|
||||
}
|
||||
default void ClearLog() {
|
||||
try {
|
||||
Utils.forceDeleteWithCheck(getLogFile());
|
||||
Utils_.forceDeleteWithCheck(getLogFile());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Common.Utils;
|
||||
import Common.CommonConstants;
|
||||
import Common.Database.VisualiserDatabase;
|
||||
import Common.Passes.PassException;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -396,6 +396,52 @@ public class Utils_ {
|
||||
os.write(bytes);
|
||||
os.close();
|
||||
}
|
||||
public static void CheckDirectory(File dir) {
|
||||
if (!dir.exists()) {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void CheckAndCleanDirectory(File dir) {
|
||||
if (dir.exists()) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null)
|
||||
for (File f : files) {
|
||||
try {
|
||||
forceDeleteWithCheck(f);
|
||||
} catch (Exception e) {
|
||||
MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
FileUtils.forceMkdir(dir);
|
||||
} catch (Exception e) {
|
||||
MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void forceDeleteWithCheck(File file) throws Exception {
|
||||
int attempts = 0;
|
||||
while (attempts < 10) {
|
||||
if (file.exists()) {
|
||||
try {
|
||||
FileUtils.forceDelete(file);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else return;
|
||||
if (file.exists()) {
|
||||
attempts++;
|
||||
System.out.println("неудачная попытка удаления: файл " + Brackets(file.getAbsolutePath()) + " занят");
|
||||
sleep(2000);
|
||||
} else return;
|
||||
}
|
||||
throw new PassException("Не удалось удалить файл " + Brackets(file.getAbsolutePath()) + " за " + attempts + " попыток");
|
||||
}
|
||||
//Иконки
|
||||
public static ImageIcon getIcon(String path) {
|
||||
URL imageUrl = Utils_.class.getResource(path);
|
||||
|
||||
Reference in New Issue
Block a user