mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 12:34:45 +08:00
feat: Cross-platform logic updates
This commit is contained in:
@ -7,6 +7,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
|
||||
class SCLoggerHelper {
|
||||
static Future<String?> getLogFilePath() async {
|
||||
if (!Platform.isWindows) return null;
|
||||
Map<String, String> envVars = Platform.environment;
|
||||
final appDataPath = envVars["appdata"];
|
||||
if (appDataPath == null) {
|
||||
@ -30,6 +31,7 @@ class SCLoggerHelper {
|
||||
}
|
||||
|
||||
static Future<List?> getLauncherLogList() async {
|
||||
if (!Platform.isWindows) return [];
|
||||
final jsonLogPath = await getLogFilePath();
|
||||
if (jsonLogPath == null) return null;
|
||||
var jsonString = utf8.decode(await File(jsonLogPath).readAsBytes());
|
||||
|
@ -263,13 +263,18 @@ foreach ($adapter in $adapterMemory) {
|
||||
|
||||
static Future openDir(path, {bool isFile = false}) async {
|
||||
dPrint("SystemHelper.openDir path === $path");
|
||||
await Process.run(SystemHelper.powershellPath,
|
||||
["explorer.exe", isFile ? "/select,$path" : "\"/select,\"$path\"\""]);
|
||||
if (Platform.isWindows) {
|
||||
await Process.run(SystemHelper.powershellPath,
|
||||
["explorer.exe", isFile ? "/select,$path" : "\"/select,\"$path\"\""]);
|
||||
}
|
||||
}
|
||||
|
||||
static String getHostsFilePath() {
|
||||
final envVars = Platform.environment;
|
||||
final systemRoot = envVars["SYSTEMROOT"];
|
||||
return "$systemRoot\\System32\\drivers\\etc\\hosts";
|
||||
if (Platform.isWindows) {
|
||||
final envVars = Platform.environment;
|
||||
final systemRoot = envVars["SYSTEMROOT"];
|
||||
return "$systemRoot\\System32\\drivers\\etc\\hosts";
|
||||
}
|
||||
return "/etc/hosts";
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ void dPrint(src) async {
|
||||
Future<void> initDPrintFile(String applicationSupportDir) async {
|
||||
final now = DateTime.now();
|
||||
final logFile =
|
||||
File("$applicationSupportDir\\logs\\${now.millisecondsSinceEpoch}.log");
|
||||
File("$applicationSupportDir/logs/${now.millisecondsSinceEpoch}.log");
|
||||
await logFile.create(recursive: true);
|
||||
_logFile = logFile;
|
||||
final logsDir = Directory("$applicationSupportDir\\logs");
|
||||
final logsDir = Directory("$applicationSupportDir/logs");
|
||||
await for (final files in logsDir.list()) {
|
||||
if (files is File) {
|
||||
final stat = await files.stat();
|
||||
|
Reference in New Issue
Block a user