mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-27 19:20:09 +00:00
Update logic code
优化补丁清单格式为二进制。
This commit is contained in:
@@ -128,19 +128,19 @@ namespace YooAsset
|
||||
{
|
||||
YooLogger.Log($"Load sandbox patch manifest file : {packageName}");
|
||||
string filePath = GetCacheManifestFilePath(packageName);
|
||||
string jsonData = File.ReadAllText(filePath);
|
||||
return PatchManifest.Deserialize(jsonData);
|
||||
byte[] bytesData = File.ReadAllBytes(filePath);
|
||||
return PatchManifest.DeserializeFromBinary(bytesData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储沙盒内清单文件
|
||||
/// </summary>
|
||||
public static PatchManifest SaveCacheManifestFile(string packageName, string fileContent)
|
||||
public static PatchManifest SaveCacheManifestFile(string packageName, byte[] fileBytesData)
|
||||
{
|
||||
YooLogger.Log($"Save sandbox patch manifest file : {packageName}");
|
||||
var manifest = PatchManifest.Deserialize(fileContent);
|
||||
var manifest = PatchManifest.DeserializeFromBinary(fileBytesData);
|
||||
string savePath = GetCacheManifestFilePath(packageName);
|
||||
FileUtility.CreateFile(savePath, fileContent);
|
||||
FileUtility.CreateFile(savePath, fileBytesData);
|
||||
return manifest;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,15 +117,25 @@ namespace YooAsset
|
||||
internal static class FileUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取文件
|
||||
/// 读取文件的文本数据
|
||||
/// </summary>
|
||||
public static string ReadFile(string filePath)
|
||||
public static string ReadAllText(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
return string.Empty;
|
||||
return File.ReadAllText(filePath, Encoding.UTF8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取文件的字节数据
|
||||
/// </summary>
|
||||
public static byte[] ReadAllBytes(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
return null;
|
||||
return File.ReadAllBytes(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件(如果已经存在则删除旧文件)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user