增加了移除Cache和Rom文件的api

This commit is contained in:
ALIENJACK\alien 2024-09-11 16:48:23 +08:00
parent f36ec11af8
commit c3804940a9
3 changed files with 24 additions and 2 deletions

View File

@ -18,6 +18,13 @@ namespace AxibugEmuOnline.Client
GetCacheData(url, TextureCacheDirPath, callback);
}
/// <summary> 移除文件缓存 </summary>
public void ClearCaches()
{
if (Directory.Exists(CacheDirPath))
Directory.Delete(CacheDirPath, true);
}
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
{
var request = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{url}");
@ -39,6 +46,7 @@ namespace AxibugEmuOnline.Client
if (cachesInMemory.TryGetValue(url, out var cacheObj) && cacheObj is T obj)
{
callback.Invoke(obj, url);
return;
}
var fileName = $"{url.GetHashCode()}";

View File

@ -1,6 +1,8 @@
using AxibugEmuOnline.Client.ClientCore;
using Codice.Client.Common;
using System;
using System.Collections.Generic;
using System.IO;
using static AxibugEmuOnline.Client.HttpAPI;
namespace AxibugEmuOnline.Client
@ -36,6 +38,20 @@ namespace AxibugEmuOnline.Client
return romFile;
}
/// <summary> 清除所有下载的Rom文件 </summary>
public void ClearRomFile()
{
var path = $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{m_platform}";
if (Directory.Exists(path)) Directory.Delete(path, true);
}
/// <summary> 移除一个已下载的Rom </summary>
public void RemoveOneRomFile(RomFile romFile)
{
if (romFile.RomReady)
File.Delete(romFile.LocalFilePath);
}
/// <summary>
/// 获得所有Rom文件
/// </summary>

View File

@ -2,8 +2,6 @@ using AxibugEmuOnline.Client.UI;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AxibugEmuOnline.Client