using System.IO;
namespace TriLibCore.SFB
{
/// Represents a platform-specific file with a Stream.
public class ItemWithStream
{
/// Gets/Sets the item filename.
public string Name { get; set; }
/// Sets the item file Stream.
public Stream Stream { private get; set; }
///
/// Indicates if this item has valid data.
///
public bool HasData => !string.IsNullOrWhiteSpace(Name) || Stream != null;
///
/// Opens the Stream to read data from this item.
///
/// The opened Stream.
public Stream OpenStream()
{
if (Stream == null && Name != null)
{
return File.OpenRead(Name);
}
return Stream;
}
}
}