This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride/Contents/FileBinaryContent.cs
D. Moonfire 9e93eb6ce6 refactor!: fixed missed namespaces
- reformatted code and cleaned up references
2023-01-14 18:19:42 -06:00

44 lines
926 B
C#

using System;
using System.IO;
namespace MfGames.Nitride.Contents;
/// <summary>
/// A binary content provider based on a file in the file system.
/// </summary>
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;
}
/// <inheritdoc />
public Stream GetStream()
{
return File.Open(
this.path,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
}
/// <inheritdoc />
public ITextContent ToTextContent()
{
return new FileTextContent(this.path);
}
}