using XGame.Framework.Utils;
using System.IO;
namespace XGame.Framework.Define
{
///
/// 框架用的 非AB文件 路径的静态定义
///
/// * 注意:
/// 1、请写相对路径
/// 2、相对于UpdatePath、WorkPath的路径
///
public static class FileDefine
{
public const string ObsoleteAssetsPrefix = "ObsoleteAssets";
public static readonly PathWrapper XGameDirectory = new("XGame");
}
///
/// XGame用的文件路径
///
public struct PathWrapper
{
public string RelativePath { get; private set; }
public PathWrapper(string relativePath)
{
RelativePath = relativePath;
}
///
/// AssetBundle文件(UpdateAssets ----no exist--->StreamAssets)
///
public string AssetBundlePath => FileUtils.GetAssetBundlePath(RelativePath).Replace("\\", "/");
///
/// 游戏文件路径(UpdateAssets ----no exist--->StreamAssets)
///
public string FilePath => FileUtils.GetFilePath(RelativePath).Replace("\\", "/");
///
/// 游戏文件URL(UpdateAssets ----no exist--->StreamAssets)
///
public string UrlPath => FileUtils.GetFileUrl(RelativePath).Replace("\\", "/");
///
/// 热更路径(UpdateAssets ----> no exist)(不会找包内路径,不存在就是不存在了)
///
public string UpdatePath => Path.Combine(PathDefine.UpdatePath, RelativePath).Replace("\\", "/");
///
/// 项目专用的沙盒目录(SandboxAssets ----> no exist)(不会找包内路径,不存在就是不存在了)
///
public string SandboxPath => Path.Combine(PathDefine.SandboxPath, RelativePath).Replace("\\", "/");
///
/// 包内StreamingAssets路径, 只读
///
public string StreamingPath => Path.Combine(PathDefine.WorkPath, RelativePath).Replace("\\", "/");
///
/// 沙盒根目录(Android下, Files目录, 项目禁止使用, 需要读写权限的目录请使用SandboxPath)
///
internal string PersistentPath => Path.Combine(PathDefine.PersistentDataPath, RelativePath).Replace("\\", "/");
///
/// 默认为FilePath!!
///
///
public static implicit operator string(PathWrapper wrapper)
{
return wrapper.FilePath;
}
}
}