【修改】 删除创建隐藏应用文件,导致文件第二次无法写入

This commit is contained in:
dlaren
2025-08-15 13:21:50 +08:00
parent df3245a2dd
commit b40ba22ef4

View File

@@ -53,24 +53,13 @@ public class LogFileUtils {
file.getParentFile().mkdirs();
}
// 对于Unix系统直接在文件名前加"."
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
String hiddenPath = file.getParent() + File.separator + "." + file.getName();
file = new File(hiddenPath);
}
// 创建文件(如果不存在)
if (!file.exists()) {
file.createNewFile();
}
// 对于Windows系统设置隐藏属性
if (System.getProperty("os.name").toLowerCase().contains("win")) {
Runtime.getRuntime().exec("attrib +H " + file.getCanonicalPath());
}
} catch (IOException e) {
throw new RuntimeException("无法创建隐藏文件: " + e.getMessage(), e);
throw new RuntimeException("无法创建文件: " + e.getMessage(), e);
}
}