Files
fluid-explorer/Services/FileSystem/IFileSystemService.cs
T

31 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using FluidExplorer.Models;
namespace FluidExplorer.Services.FileSystem;
/// <summary>
/// 快速目录枚举:内部使用 .NET 的 FileSystemEnumerable(NtQueryDirectoryFile 批量缓冲)
/// 一次取回名称/属性/大小/时间,避免逐文件 Win32 调用。
/// </summary>
public interface IFileSystemService
{
/// <summary>
/// 异步枚举目录,分批回调(首批尽可能快,保证 UI 立刻有内容),
/// 整体可取消;无权限/网络超时不抛异常,通过 listing.Error 汇报。
/// </summary>
Task EnumerateAsync(
string path,
FolderListing listing,
Func<IReadOnlyList<FileEntry>, Task> onBatch,
int batchSize = 256,
CancellationToken cancellationToken = default);
/// <summary>同步枚举(供后台索引/搜索回退用),返回全部条目。</summary>
IReadOnlyList<FileEntry> Enumerate(string path, bool includeHidden = true);
bool DirectoryExists(string path);
bool FileExists(string path);
/// <summary>计算文件夹大小(后台、可取消)。</summary>
Task<long> GetDirectorySizeAsync(string path, CancellationToken cancellationToken);
}