// // FileArchive.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Remora.Results; namespace NosSmooth.Data.NOSFiles.Files; /// /// An archive of files. /// /// The files in the archive. public record FileArchive(IReadOnlyList Files) { /// /// Try to find the given file. /// /// The name of the file. /// A file or an error. public Result FindFile(string name) { var foundFile = Files.OfType().FirstOrDefault (x => Path.GetFileName(((RawFile)x!).Path) == name, null); if (foundFile is null) { return new NotFoundError($"Could not find file {name} in archive."); } return (RawFile)foundFile; } }