mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[FileTypes/] Cleanup tabs AND variables
This commit is contained in:
@@ -9,151 +9,115 @@ using Stream = System.IO.Stream;
|
||||
|
||||
namespace SabreTools.Library.FileTypes
|
||||
{
|
||||
public class BaseFile
|
||||
{
|
||||
#region Protected instance variables
|
||||
public class BaseFile
|
||||
{
|
||||
#region Publicly facing variables
|
||||
|
||||
protected FileType _fileType;
|
||||
protected string _filename;
|
||||
protected string _parent;
|
||||
protected string _date;
|
||||
// TODO: Get all of these values automatically so there is no public "set"
|
||||
public FileType Type { get; protected set; }
|
||||
public string Filename { get; set; }
|
||||
public string Parent { get; set; }
|
||||
public string Date { get; set; }
|
||||
public long? Size { get; set; }
|
||||
public byte[] CRC { get; set; }
|
||||
public byte[] MD5 { get; set; }
|
||||
public byte[] SHA1 { get; set; }
|
||||
public byte[] SHA256 { get; set; }
|
||||
public byte[] SHA384 { get; set; }
|
||||
public byte[] SHA512 { get; set; }
|
||||
|
||||
// External hash values for the file
|
||||
protected long? _size;
|
||||
protected byte[] _crc;
|
||||
protected byte[] _md5;
|
||||
protected byte[] _sha1;
|
||||
protected byte[] _sha256;
|
||||
protected byte[] _sha384;
|
||||
protected byte[] _sha512;
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Construtors
|
||||
|
||||
#region Publicly facing variables
|
||||
/// <summary>
|
||||
/// Create a new BaseFile with no base file
|
||||
/// </summary>
|
||||
public BaseFile()
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: Get all of these values automatically so there is no public "set"
|
||||
public FileType Type
|
||||
{
|
||||
get { return _fileType; }
|
||||
}
|
||||
public string Filename
|
||||
{
|
||||
get { return _filename; }
|
||||
set { _filename = value; }
|
||||
}
|
||||
public string Parent
|
||||
{
|
||||
get { return _parent; }
|
||||
set { _parent = value; }
|
||||
}
|
||||
public string Date
|
||||
{
|
||||
get { return _date; }
|
||||
set { _date = value; }
|
||||
}
|
||||
public long? Size
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
public byte[] CRC
|
||||
{
|
||||
get { return _crc; }
|
||||
set { _crc = value; }
|
||||
}
|
||||
public byte[] MD5
|
||||
{
|
||||
get { return _md5; }
|
||||
set { _md5 = value; }
|
||||
}
|
||||
public byte[] SHA1
|
||||
{
|
||||
get { return _sha1; }
|
||||
set { _sha1 = value; }
|
||||
}
|
||||
public byte[] SHA256
|
||||
{
|
||||
get { return _sha256; }
|
||||
set { _sha256 = value; }
|
||||
}
|
||||
public byte[] SHA384
|
||||
{
|
||||
get { return _sha384; }
|
||||
set { _sha384 = value; }
|
||||
}
|
||||
public byte[] SHA512
|
||||
{
|
||||
get { return _sha512; }
|
||||
set { _sha512 = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a new BaseFile from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||
public BaseFile(string filename, bool getHashes = true)
|
||||
{
|
||||
this.Filename = filename;
|
||||
|
||||
#endregion
|
||||
if (getHashes)
|
||||
{
|
||||
BaseFile temp = Utilities.GetFileInfo(this.Filename);
|
||||
|
||||
#region Construtors
|
||||
if (temp != null)
|
||||
{
|
||||
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 with no base file
|
||||
/// </summary>
|
||||
public BaseFile()
|
||||
{
|
||||
}
|
||||
/// <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>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||
public BaseFile(string filename, Stream stream, bool getHashes = true)
|
||||
{
|
||||
this.Filename = filename;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new BaseFile from the given file
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use</param>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||
public BaseFile(string filename, bool getHashes = true)
|
||||
{
|
||||
this._filename = filename;
|
||||
if (getHashes)
|
||||
{
|
||||
BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length);
|
||||
|
||||
if (getHashes)
|
||||
{
|
||||
BaseFile temp = Utilities.GetFileInfo(_filename);
|
||||
if(temp != null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
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 metadata
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to use</param>
|
||||
/// <param name="parent">Parent folder or archive</param>
|
||||
/// <param name="date">File date</param>
|
||||
/// <param name="crc">CRC hash as a byte array</param>
|
||||
/// <param name="md5">MD5 hash as a byte array</param>
|
||||
/// <param name="sha1">SHA-1 hash as a byte array</param>
|
||||
/// <param name="sha256">SHA-256 hash as a byte array</param>
|
||||
/// <param name="sha384">SHA-384 hash as a byte array</param>
|
||||
/// <param name="sha512">SHA-512 hash as a byte array</param>
|
||||
public BaseFile(string filename, string parent, string date, byte[] crc, byte[] md5, byte[] sha1, byte[] sha256, byte[] sha384, byte[] sha512)
|
||||
{
|
||||
this.Filename = filename;
|
||||
this.Parent = parent;
|
||||
this.Date = date;
|
||||
this.CRC = crc;
|
||||
this.MD5 = md5;
|
||||
this.SHA1 = sha1;
|
||||
this.SHA256 = sha256;
|
||||
this.SHA384 = sha384;
|
||||
this.SHA512 = 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>
|
||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||
public BaseFile(string filename, Stream stream, bool getHashes = true)
|
||||
{
|
||||
this._filename = filename;
|
||||
|
||||
if (getHashes)
|
||||
{
|
||||
BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length);
|
||||
|
||||
if(temp != null)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user