123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- namespace XGame.Framework.FileSystem
- {
- /// <summary>
- /// 文件操作接口
- /// </summary>
- public interface IFileOperator
- {
- /// <summary>
- /// 获取文件名
- /// </summary>
- /// <param name="fullName"></param>
- /// <param name="withoutExt"></param>
- /// <returns></returns>
- string GetFileName(string fullName, bool withoutExt = true);
- /// <summary>
- /// 拓展名
- /// </summary>
- /// <param name="fullName">文件全路径(含拓展名)</param>
- /// <returns>拓展名(不包含“.”)</returns>
- string Extension(string fullName);
- /// <summary>
- /// 文件是否存在
- /// </summary>
- /// <param name="fullName">文件全路径(含拓展名)</param>
- /// <returns>True: 存在; False: 不存在; </returns>
- bool Exist(string fullName);
- /// <summary>
- /// 删除文件
- /// </summary>
- /// <param name="fullName">文件全路径(含拓展名)</param>
- /// <returns>True: 删除成功; False: 删除失败;</returns>
- bool Delete(string fullName);
- /// <summary>
- /// 获取文件所在文件夹路径(全路径)
- /// </summary>
- /// <param name="fullName">文件全路径(含拓展名)</param>
- /// <returns>文件夹全路径</returns>
- string GetDirectory(string fullName);
- /// <summary>
- /// 复制文件
- /// TODO: 暂时只支持包外文件到包外
- /// </summary>
- /// <param name="source">源文件</param>
- /// <param name="destination">目标文件</param>
- /// <param name="overwrite">是否覆盖</param>
- /// <returns>True: 复制成功; False: 复制失败;</returns>
- bool Copy(string source, string destination, bool overwrite);
- /// <summary>
- /// 异步复制文件
- /// </summary>
- /// <param name="source">源文件</param>
- /// <param name="destination">包外文件全路径</param>
- /// <param name="overwrite">覆盖</param>
- /// <returns></returns>
- ICopyFileAsync CopyFileAsync(string source, string destination, bool overwrite);
- /// <summary>
- /// 移动文件
- /// </summary>
- /// <param name="source">源文件</param>
- /// <param name="destination">目标文件路径</param>
- void Move(string source, string destination);
- /// <summary>
- /// 保存字节数组到本地
- /// </summary>
- /// <param name="filePath">文件全路径(包外)</param>
- /// <param name="bytes"></param>
- void WriteAllBytes(string filePath, byte[] bytes);
- /// <summary>
- /// 保存字符串到本地
- /// </summary>
- /// <param name="filePath">文件全路径(包外)</param>
- /// <param name="contents">内容</param>
- void WriteAllText(string filePath, string contents);
- /// <summary>
- /// 读取文件
- /// </summary>
- /// <param name="filePath">文件全路径(包内包外都可以)</param>
- /// <returns>文件内容</returns>
- byte[] ReadAllBytes(string filePath);
- /// <summary>
- /// 读取文本(UTF-8)
- /// </summary>
- /// <param name="filePath">文件全路径(包内包外都可以)</param>
- /// <returns>文本内容</returns>
- string ReadAllText(string filePath);
- /// <summary>
- /// 异步读取文件
- /// </summary>
- /// <param name="filePath">文件全路径(包内包外都可以)</param>
- /// <returns>文件内容</returns>
- IReadFileAsync ReadFileAsync(string filePath);
- /// <summary>
- /// 重命名
- /// </summary>
- /// <param name="from"></param>
- /// <param name="to"></param>
- /// <returns></returns>
- bool Rename(string from, string to);
- }
- }
|