From 2b051b7a277ca389081036684e80cecd32b5337d Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Fri, 20 Sep 2024 17:10:18 +0800 Subject: [PATCH] hash | PSVita dir --- AxibugEmuOnline.Client/Assets/Script/App.cs | 20 ++++++++++++++++++- .../Assets/Script/Common/Helper.cs | 17 ++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/App.cs b/AxibugEmuOnline.Client/Assets/Script/App.cs index 858b6ec..c9ce855 100644 --- a/AxibugEmuOnline.Client/Assets/Script/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/App.cs @@ -1,6 +1,7 @@ using AxibugEmuOnline.Client.Manager; using AxibugEmuOnline.Client.Network; using System.Collections; +using System.IO; using System.Threading.Tasks; using UnityEngine; using UnityEngine.Networking; @@ -31,8 +32,11 @@ namespace AxibugEmuOnline.Client.ClientCore private static CoroutineRunner coRunner; #endregion - +#if UNITY_PSP2 + public static string PersistentDataPath => "ux0:data/AxibugEmu"; +#else public static string PersistentDataPath => Application.persistentDataPath; +#endif [RuntimeInitializeOnLoadMethod] static void Init() @@ -56,6 +60,12 @@ namespace AxibugEmuOnline.Client.ClientCore tickLoop = go.AddComponent(); coRunner = go.AddComponent(); + if (UnityEngine.Application.platform == RuntimePlatform.PSP2) + { + //PSV 等平台需要手动创建目录 + PersistentDataPathDir(); + } + var importNode = GameObject.Find("IMPORTENT"); GameObject.DontDestroyOnLoad(importNode); @@ -63,6 +73,14 @@ namespace AxibugEmuOnline.Client.ClientCore RePullNetInfo(); } + private static void PersistentDataPathDir() + { + if (!Directory.Exists(PersistentDataPath)) + { + Directory.CreateDirectory(PersistentDataPath); + } + } + private static IEnumerator AppTickFlow() { while (true) diff --git a/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs b/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs index 9e9b8d2..6cf5c99 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Common/Helper.cs @@ -1,6 +1,8 @@ using System; using System.IO; using System.IO.Compression; +using System.Security.Cryptography; +using System.Text; namespace AxibugEmuOnline.Client.Common { @@ -42,5 +44,20 @@ namespace AxibugEmuOnline.Client.Common return resultMemoryStream.ToArray(); } } + + public static string FileMD5Hash(string filePath) + { + using (var md5 = MD5.Create()) + { + using (var stream = File.OpenRead(filePath)) + { + var hash = md5.ComputeHash(stream); + var sb = new StringBuilder(hash.Length * 2); + foreach (var b in hash) + sb.AppendFormat("{0:x2}", b); + return sb.ToString(); + } + } + } } }