mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-11 18:57:30 +03:00
[FEATURE] Автоматическая установка флага executable на линуксе.
This commit is contained in:
parent
e172cb194a
commit
238d604b71
1 changed files with 16 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
|
@ -24,7 +25,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
|||
}
|
||||
}
|
||||
|
||||
public static Instrumentation inst;
|
||||
public static Instrumentation inst = null;
|
||||
public static Path libraries = null;
|
||||
private static boolean isStarted = false;
|
||||
|
||||
public static boolean isAgentStarted() {
|
||||
|
@ -35,9 +37,20 @@ public static void premain(String agentArgument, Instrumentation inst) {
|
|||
StarterAgent.inst = inst;
|
||||
isStarted = true;
|
||||
try {
|
||||
Files.walkFileTree(Paths.get("libraries"), Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new StarterVisitor(inst));
|
||||
} catch (IOException e) {
|
||||
libraries = Paths.get("libraries");
|
||||
if (ManagementFactory.getOperatingSystemMXBean().getName().startsWith("Linux"))
|
||||
fixLibsPerms();
|
||||
Files.walkFileTree(libraries, Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new StarterVisitor(inst));
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
private static void fixLibsPerms() throws InterruptedException, IOException {
|
||||
Path file = libraries.resolve(".libraries_chmoded");
|
||||
if (Files.exists(file)) return;
|
||||
Files.deleteIfExists(file);
|
||||
Runtime.getRuntime().exec(new String[] {"chmod", "-R", "+x", "libraries"}, null, libraries.toAbsolutePath().normalize().toFile().getParentFile()).waitFor();
|
||||
Files.createFile(file);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue