[BaseFIle] Add stream constructor

This commit is contained in:
Matt Nadareski
2018-02-16 00:23:49 -08:00
parent d36cff2f9b
commit 6d2c102408

View File

@@ -1,6 +1,11 @@
using System.Collections.Generic; using SabreTools.Library.Data;
using SabreTools.Library.Tools;
using SabreTools.Library.Data; #if MONO
using System.IO;
#else
using Stream = System.IO.Stream;
#endif
namespace SabreTools.Library.FileTypes namespace SabreTools.Library.FileTypes
{ {
@@ -87,19 +92,49 @@ namespace SabreTools.Library.FileTypes
#region Construtors #region Construtors
/// <summary> /// <summary>
/// Create a new Archive with no base file /// Create a new BaseFile with no base file
/// </summary> /// </summary>
public BaseFile() public BaseFile()
{ {
} }
/// <summary> /// <summary>
/// Create a new Archive from the given file /// Create a new BaseFile from the given file
/// </summary> /// </summary>
/// <param name="filename">Name of the file to use as an archive</param> /// <param name="filename">Name of the file to use</param>
public BaseFile(string filename) public BaseFile(string filename)
{ {
_filename = filename; BaseFile temp = Utilities.GetFileInfo(_filename);
this._filename = temp.Filename;
this._parent = temp.Parent;
this._date = temp.Date;
this._crc = temp.CRC;
this._md5 = temp.MD5;
this._sha1 = temp.SHA1;
this._sha256 = temp.SHA256;
this._sha384 = temp.SHA384;
this._sha512 = temp.SHA512;
}
/// <summary>
/// Create a new BaseFile from the given file
/// </summary>
/// <param name="filename">Name of the file to use</param>
/// <param name="stream">Stream to populate information from</param>
public BaseFile(string filename, Stream stream)
{
BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length);
this._filename = temp.Filename;
this._parent = temp.Parent;
this._date = temp.Date;
this._crc = temp.CRC;
this._md5 = temp.MD5;
this._sha1 = temp.SHA1;
this._sha256 = temp.SHA256;
this._sha384 = temp.SHA384;
this._sha512 = temp.SHA512;
} }
#endregion #endregion