refactor : default cache file system

This commit is contained in:
何冠峰
2024-12-12 17:35:42 +08:00
parent 9607d7135b
commit 97f9a3d4b1
15 changed files with 333 additions and 277 deletions

View File

@@ -10,36 +10,6 @@ namespace YooAsset
/// </summary>
internal class DefaultBuildinFileSystem : IFileSystem
{
private class UnpackRemoteServices : IRemoteServices
{
private readonly string _buildinPackageRoot;
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
public UnpackRemoteServices(string buildinPackRoot)
{
_buildinPackageRoot = buildinPackRoot;
}
string IRemoteServices.GetRemoteMainURL(string fileName)
{
return GetFileLoadURL(fileName);
}
string IRemoteServices.GetRemoteFallbackURL(string fileName)
{
return GetFileLoadURL(fileName);
}
private string GetFileLoadURL(string fileName)
{
if (_mapping.TryGetValue(fileName, out string url) == false)
{
string filePath = PathUtility.Combine(_buildinPackageRoot, fileName);
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_mapping.Add(fileName, url);
}
return url;
}
}
public class FileWrapper
{
public string FileName { private set; get; }
@@ -220,7 +190,7 @@ namespace YooAsset
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
// 创建解压文件系统
var remoteServices = new UnpackRemoteServices(_packageRoot);
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
_unpackFileSystem = new DefaultUnpackFileSystem();
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
@@ -231,6 +201,7 @@ namespace YooAsset
}
public virtual void OnUpdate()
{
_unpackFileSystem.OnUpdate();
}
public virtual bool Belong(PackageBundle bundle)