using System; using System.IO; namespace MfGames.Nitride.Contents; /// /// A binary content provider based on a file in the file system. /// public class FileBinaryContent : IBinaryContent, ITextContentConvertable { private readonly string path; public FileBinaryContent(string path) { this.path = path ?? throw new ArgumentNullException(nameof(path)); } public FileBinaryContent(FileInfo file) { if (file == null) { throw new ArgumentNullException(nameof(file)); } this.path = file.FullName; } /// public Stream GetStream() { return File.Open( this.path, FileMode.Open, FileAccess.Read, FileShare.Read); } /// public ITextContent ToTextContent() { return new FileTextContent(this.path); } }