61 lines
1.6 KiB
Dart
61 lines
1.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:servermanager/structs/settings.dart';
|
|
|
|
Future<void> runProton(String command, List<String> argx) async {
|
|
Settings settings = Settings();
|
|
Directory dir =
|
|
Directory("${settings.game_path}${Platform.pathSeparator}pfx");
|
|
|
|
if (dir.existsSync()) {
|
|
await dir.delete(recursive: true);
|
|
}
|
|
await dir.create(recursive: true);
|
|
|
|
Map<String, String> env = Map.from(Platform.environment);
|
|
env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam";
|
|
env["STEAM_COMPAT_DATA_PATH"] = dir.path;
|
|
|
|
try {
|
|
List<String> args = ["run", command];
|
|
args.addAll(argx);
|
|
|
|
ProcessResult res = await Process.run(
|
|
"proton", args, // Run arbitrary command with arguments
|
|
environment: env,
|
|
);
|
|
|
|
print('Exit code: ${res.exitCode}');
|
|
print('stdout: ${res.stdout}');
|
|
print('stderr: ${res.stderr}');
|
|
} catch (e) {
|
|
print('Error executing command: $e');
|
|
}
|
|
}
|
|
|
|
Future<void> runDetachedProton(
|
|
String command, List<String> argx, String workingDir) async {
|
|
Settings settings = Settings();
|
|
Directory dir =
|
|
Directory("${settings.game_path}${Platform.pathSeparator}pfx");
|
|
|
|
if (dir.existsSync()) {
|
|
await dir.delete(recursive: true);
|
|
}
|
|
await dir.create(recursive: true);
|
|
|
|
Map<String, String> env = Map.from(Platform.environment);
|
|
env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam";
|
|
env["STEAM_COMPAT_DATA_PATH"] = dir.path;
|
|
|
|
try {
|
|
List<String> args = ["run", command];
|
|
args.addAll(argx);
|
|
|
|
Process.start("proton", args, // Run arbitrary command with arguments
|
|
environment: env,
|
|
workingDirectory: workingDir);
|
|
} catch (e) {
|
|
print('Error executing command: $e');
|
|
}
|
|
}
|