mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-02-04 23:51:19 +01:00
detecting old directory (MacOS)
This commit is contained in:
parent
4e16fce61f
commit
57f2f6a89e
@ -20,6 +20,9 @@ import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -183,7 +186,7 @@ public class Bootstrap {
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static File getFileChooseDefaultDir() {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
FileSystemView fsv = chooser.getFileSystemView();
|
||||
@ -195,7 +198,20 @@ public class Bootstrap {
|
||||
if (osName.contains("win")) {
|
||||
return new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderWindows"));
|
||||
} else if (osName.contains("mac") && getProperties().getProperty("homeFolderMac") != null) {
|
||||
return new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderMac"));
|
||||
// this scope can be replaced with: return new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderMac"));
|
||||
File macHomeFolder = new File(getFileChooseDefaultDir(), getProperties().getProperty("homeFolderMac"));
|
||||
try {
|
||||
if (!macHomeFolder.exists()) {
|
||||
File standartHomeFolder = new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
|
||||
if (standartHomeFolder.exists()) {
|
||||
log.info("Found launcher directory at the wrong place... Moving " + standartHomeFolder.getAbsolutePath() + " to " + macHomeFolder.getAbsolutePath() + "...");
|
||||
Files.move(Paths.get(standartHomeFolder.getPath()), Paths.get(macHomeFolder.getPath()), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.log(Level.WARNING, "Error occurred while moving the directory. Creating and using new laucher directory (" + macHomeFolder.getAbsolutePath() + ").", e);
|
||||
}
|
||||
return macHomeFolder;
|
||||
} else {
|
||||
return new File(System.getProperty("user.home"), getProperties().getProperty("homeFolder"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user