修改开机自启文件复制逻辑

This commit is contained in:
yang 2022-10-14 17:45:47 +08:00
parent fe3731d613
commit 2cdefbd8b9
1 changed files with 20 additions and 8 deletions

View File

@ -31,9 +31,27 @@ public class AutoStartFile {
private static void generate() {
try {
if (new File(START_UP_FILE_PATH).exists()) {
StringJoiner fileContentJoiner = new StringJoiner("\n");
String driveLetter = AUTO_START_EXEC_FILE_PATH.substring(0, 2);
fileContentJoiner.add("@echo off");
fileContentJoiner.add(driveLetter);
fileContentJoiner.add("cd " + ResourceUtils.getResourceByProject(""));
fileContentJoiner.add("RoomIt");
String fileContent = fileContentJoiner.toString();
File startUpFile = new File(START_UP_FILE_PATH);
if (startUpFile.exists()) {
FileInputStream is = new FileInputStream(startUpFile);
boolean isSame = new String(is.readAllBytes()).equals(fileContent);
is.close();
if (isSame) {
return;
}
}
File file = new File(BAT_FILE_PATH);
@ -43,12 +61,6 @@ public class AutoStartFile {
FileWriter fos = new FileWriter(file);
StringJoiner fileContentJoiner = new StringJoiner("\n");
String driveLetter = AUTO_START_EXEC_FILE_PATH.substring(0, 2);
fileContentJoiner.add("@echo off");
fileContentJoiner.add(driveLetter);
fileContentJoiner.add("cd " + ResourceUtils.getResourceByProject(""));
fileContentJoiner.add("RoomIt");
fos.write(fileContentJoiner.toString());
fos.flush();