mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Папка лаунчера перемещена в AppData(Windows) .minecraftlauncher(Linux)
This commit is contained in:
parent
69a90dc806
commit
3654a450f8
2 changed files with 59 additions and 1 deletions
|
@ -20,7 +20,7 @@ var config = {
|
||||||
|
|
||||||
// ====== DON'T TOUCH! ====== //
|
// ====== DON'T TOUCH! ====== //
|
||||||
|
|
||||||
DirBridge.dir = IOHelper.HOME_DIR.resolve(config.dir);
|
DirBridge.dir = DirBridge.getLauncherDir(config.dir);
|
||||||
if (!IOHelper.isDir(DirBridge.dir)) {
|
if (!IOHelper.isDir(DirBridge.dir)) {
|
||||||
java.nio.file.Files.createDirectory(DirBridge.dir);
|
java.nio.file.Files.createDirectory(DirBridge.dir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package ru.gravit.launcher.client;
|
package ru.gravit.launcher.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import ru.gravit.launcher.LauncherAPI;
|
import ru.gravit.launcher.LauncherAPI;
|
||||||
import ru.gravit.utils.helper.IOHelper;
|
import ru.gravit.utils.helper.IOHelper;
|
||||||
|
import ru.gravit.utils.helper.JVMHelper;
|
||||||
|
|
||||||
public class DirBridge {
|
public class DirBridge {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -14,9 +17,64 @@ public class DirBridge {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static Path defaultUpdatesDir;
|
public static Path defaultUpdatesDir;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
public static boolean useLegacyDir;
|
||||||
|
@LauncherAPI
|
||||||
public static void move(Path newDir) throws IOException
|
public static void move(Path newDir) throws IOException
|
||||||
{
|
{
|
||||||
IOHelper.move(dirUpdates,newDir);
|
IOHelper.move(dirUpdates,newDir);
|
||||||
dirUpdates = newDir;
|
dirUpdates = newDir;
|
||||||
}
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static Path getAppDataDir() throws IOException {
|
||||||
|
Boolean isCustomDir = Boolean.getBoolean(System.getProperty("launcher.usecustomdir","false"));
|
||||||
|
if(isCustomDir)
|
||||||
|
{
|
||||||
|
return Paths.get(System.getProperty("launcher.customdir"));
|
||||||
|
}
|
||||||
|
if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX)
|
||||||
|
{
|
||||||
|
Boolean isOpt = Boolean.getBoolean(System.getProperty("launcher.useoptdir","false"));
|
||||||
|
if(isOpt)
|
||||||
|
{
|
||||||
|
Path opt = Paths.get("/").resolve("opt");
|
||||||
|
if(!IOHelper.isDir(opt)) Files.createDirectories(opt);
|
||||||
|
return opt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Path local = IOHelper.HOME_DIR.resolve(".minecraftlauncher");
|
||||||
|
if(!IOHelper.isDir(local)) Files.createDirectories(local);
|
||||||
|
return local;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE)
|
||||||
|
{
|
||||||
|
Path appdata = IOHelper.HOME_DIR.resolve("AppData").resolve("Roaming");
|
||||||
|
if(!IOHelper.isDir(appdata)) Files.createDirectories(appdata);
|
||||||
|
return appdata;
|
||||||
|
}
|
||||||
|
else if(JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX)
|
||||||
|
{
|
||||||
|
Path minecraft = IOHelper.HOME_DIR.resolve("minecraft");
|
||||||
|
if(!IOHelper.isDir(minecraft)) Files.createDirectories(minecraft);
|
||||||
|
return minecraft;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return IOHelper.HOME_DIR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static Path getLauncherDir(String projectname) throws IOException {
|
||||||
|
return getAppDataDir().resolve(projectname);
|
||||||
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static Path getLegacyLauncherDir(String projectname) throws IOException {
|
||||||
|
return IOHelper.HOME_DIR.resolve(projectname);
|
||||||
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static void setUseLegacyDir(boolean b)
|
||||||
|
{
|
||||||
|
useLegacyDir = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue