import 'dart:io'; import 'package:libac_dart/utils/IOTools.dart'; import 'package:servermanager/statemachine.dart'; import 'package:servermanager/structs/settings.dart'; Future runProton(String command, List argx) async { Settings settings = Settings(); Directory dir = Directory(PathHelper.builder(settings.base_path).resolve("pfx").build()); if (dir.existsSync()) { await dir.delete(recursive: true); } await dir.create(recursive: true); Map env = Map.from(Platform.environment); env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam"; env["STEAM_COMPAT_DATA_PATH"] = dir.path; try { List args = ["run", command]; args.addAll(argx); ProcessResult res = await Process.run( settings.getProtonExecutablePath(), 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 runDetachedProton( String command, List argx, String workingDir) async { Settings settings = Settings(); Directory dir = Directory(PathHelper.builder(settings.base_path).resolve("pfx").build()); if (dir.existsSync()) { await dir.delete(recursive: true); } await dir.create(recursive: true); Map env = Map.from(Platform.environment); env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam"; env["STEAM_COMPAT_DATA_PATH"] = dir.path; try { List args = ["run", command]; args.addAll(argx); StateMachine.PROC = await Process.start(settings.getProtonExecutablePath(), args, // Run arbitrary command with arguments environment: env, workingDirectory: workingDir); StateMachine.monitorProcess(); } catch (e) { print('Error executing command: $e'); } }