public static PakVFS OpenAt(string path, IVersionProvider?versionProvider = null, IAesKeyProvider?keyProvider = null) { if (path is null) { throw new ArgumentNullException(nameof(path)); } var dir = new DirectoryInfo(path); if (!dir.Exists) { throw new DirectoryNotFoundException(); } var paks = dir.GetFiles(PakExtensionPattern).Select(f => PakFile.Open(f, versionProvider, keyProvider)).OfType <PakFile>(); return(new PakVFS(paks)); }
public async static ValueTask <PakVFS> OpenAtAsync(string path, IVersionProvider?versionProvider = null, IAesKeyProvider?keyProvider = null, CancellationToken cancellationToken = default) { if (path is null) { throw new ArgumentNullException(nameof(path)); } var dir = new DirectoryInfo(path); if (!dir.Exists) { throw new DirectoryNotFoundException(); } var files = dir.GetFiles(PakExtensionPattern); var tasks = files.Select(f => PakFile.OpenAsync(f, versionProvider, cancellationToken: cancellationToken)); var paks = await Task.WhenAll(tasks).ConfigureAwait(false); return(new PakVFS(paks.Where(x => x != null))); }
public PakEntry(PakFile pakFile) => Owner = pakFile;