diff --git a/lib/common/helper/log_helper.dart b/lib/common/helper/log_helper.dart index abfc8af..0a40ba3 100644 --- a/lib/common/helper/log_helper.dart +++ b/lib/common/helper/log_helper.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:hive/hive.dart'; +import 'package:starcitizen_doctor/common/conf/const_conf.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; class SCLoggerHelper { @@ -115,6 +116,15 @@ class SCLoggerHelper { return scInstallPaths; } + static String getGameChannelID(String installPath) { + for (var value in ConstConf.gameChannels) { + if (installPath.endsWith("\\$value")) { + return value; + } + } + return "UNKNOWN"; + } + static Future?> getGameRunningLogs(String gameDir) async { final logFile = File("$gameDir/Game.log"); if (!await logFile.exists()) { diff --git a/lib/provider/unp4kc.dart b/lib/provider/unp4kc.dart index 9e14569..0f6d36b 100644 --- a/lib/provider/unp4kc.dart +++ b/lib/provider/unp4kc.dart @@ -4,8 +4,10 @@ import 'dart:io'; import 'package:file/memory.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:starcitizen_doctor/common/conf/binary_conf.dart'; +import 'package:starcitizen_doctor/common/helper/log_helper.dart'; import 'package:starcitizen_doctor/common/rust/api/rs_process.dart'; import 'package:starcitizen_doctor/common/utils/log.dart'; import 'package:starcitizen_doctor/common/utils/provider.dart'; @@ -199,7 +201,9 @@ class Unp4kCModel extends _$Unp4kCModel { } openFile(String filePath) async { - final tempPath = "${appGlobalState.applicationSupportDir}\\temp\\unp4k\\"; + final tempDir = await getTemporaryDirectory(); + final tempPath = + "${tempDir.absolute.path}\\SCToolbox_unp4kc\\${SCLoggerHelper.getGameChannelID(getGamePath())}\\"; state = state.copyWith( tempOpenFile: const MapEntry("loading", ""), endMessage: "读取文件:$filePath ...");