feat: update unp4k

This commit is contained in:
xkeyC
2025-12-04 16:06:49 +08:00
parent e3c3986379
commit e1ed30b6e6
14 changed files with 362 additions and 411 deletions

View File

@@ -51,12 +51,12 @@ class Unp4kCModel extends _$Unp4kCModel {
final loadStartTime = DateTime.now();
// 使用 Rust API 打开 P4K 文件(异步
// 使用 Rust API 打开 P4K 文件(仅打开,不读取文件列表
await unp4k_api.p4KOpen(p4KPath: gameP4kPath);
state = state.copyWith(endMessage: S.current.tools_unp4k_msg_reading2);
// 获取所有文件列表(异步
// 获取所有文件列表(会触发文件列表加载
final p4kFiles = await unp4k_api.p4KGetAllFiles();
final files = <String, AppUnp4kP4kItemData>{};
@@ -70,6 +70,7 @@ class Unp4kCModel extends _$Unp4kCModel {
isDirectory: item.isDirectory,
size: item.size.toInt(),
compressedSize: item.compressedSize.toInt(),
dateModified: item.dateModified,
);
files[item.name] = fileData;
@@ -158,7 +159,7 @@ class Unp4kCModel extends _$Unp4kCModel {
tempOpenFile: const MapEntry("loading", ""),
endMessage: S.current.tools_unp4k_msg_open_file(filePath),
);
extractFile(filePath, tempPath, mode: "extract_open");
await extractFile(filePath, tempPath, mode: "extract_open");
}
Future<void> extractFile(String filePath, String outputPath, {String mode = "extract"}) async {
@@ -171,6 +172,7 @@ class Unp4kCModel extends _$Unp4kCModel {
final fullOutputPath = "$outputPath$filePath";
dPrint("extractFile .... $filePath -> $fullOutputPath");
// 使用 Rust API 提取到磁盘
await unp4k_api.p4KExtractToDisk(filePath: filePath, outputPath: fullOutputPath);
if (mode == "extract_open") {
@@ -198,11 +200,6 @@ class Unp4kCModel extends _$Unp4kCModel {
}
}
static bool checkRunTimeError(String errorMessage) {
// Rust 实现不再需要 .NET runtime这个方法保留以兼容现有代码
return false;
}
/// 从 P4K 文件中提取指定文件到内存
/// [p4kPath] P4K 文件路径
/// [filePath] 要提取的文件路径P4K 内部路径)

View File

@@ -41,7 +41,7 @@ final class Unp4kCModelProvider
}
}
String _$unp4kCModelHash() => r'fe88d52b11464fdbded606bacbd833c1e908b738';
String _$unp4kCModelHash() => r'a296a499158e78848a698c3fda92c4c88ff039be';
abstract class _$Unp4kCModel extends $Notifier<Unp4kcState> {
Unp4kcState build();