mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[FileTypes] Add "hashing" defaults
This commit is contained in:
@@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new Archive from the given file
|
/// Create a new Archive 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 as an archive</param>
|
||||||
public BaseArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public BaseArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,21 +102,26 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new BaseFile from the given file
|
/// Create a new BaseFile from the given file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use</param>
|
/// <param name="filename">Name of the file to use</param>
|
||||||
public BaseFile(string filename)
|
/// <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;
|
this._filename = filename;
|
||||||
BaseFile temp = Utilities.GetFileInfo(_filename);
|
|
||||||
|
|
||||||
if (temp != null)
|
if (getHashes)
|
||||||
{
|
{
|
||||||
this._parent = temp.Parent;
|
BaseFile temp = Utilities.GetFileInfo(_filename);
|
||||||
this._date = temp.Date;
|
|
||||||
this._crc = temp.CRC;
|
if (temp != null)
|
||||||
this._md5 = temp.MD5;
|
{
|
||||||
this._sha1 = temp.SHA1;
|
this._parent = temp.Parent;
|
||||||
this._sha256 = temp.SHA256;
|
this._date = temp.Date;
|
||||||
this._sha384 = temp.SHA384;
|
this._crc = temp.CRC;
|
||||||
this._sha512 = temp.SHA512;
|
this._md5 = temp.MD5;
|
||||||
|
this._sha1 = temp.SHA1;
|
||||||
|
this._sha256 = temp.SHA256;
|
||||||
|
this._sha384 = temp.SHA384;
|
||||||
|
this._sha512 = temp.SHA512;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,19 +130,28 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use</param>
|
/// <param name="filename">Name of the file to use</param>
|
||||||
/// <param name="stream">Stream to populate information from</param>
|
/// <param name="stream">Stream to populate information from</param>
|
||||||
public BaseFile(string filename, Stream stream)
|
/// <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)
|
||||||
{
|
{
|
||||||
BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length);
|
|
||||||
|
|
||||||
this._filename = filename;
|
this._filename = filename;
|
||||||
this._parent = temp.Parent;
|
|
||||||
this._date = temp.Date;
|
if (getHashes)
|
||||||
this._crc = temp.CRC;
|
{
|
||||||
this._md5 = temp.MD5;
|
BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length);
|
||||||
this._sha1 = temp.SHA1;
|
|
||||||
this._sha256 = temp.SHA256;
|
if(temp != null)
|
||||||
this._sha384 = temp.SHA384;
|
{
|
||||||
this._sha512 = temp.SHA512;
|
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
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public Folder(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public Folder(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.Folder;
|
_fileType = FileType.Folder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public GZipArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public GZipArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.GZipArchive;
|
_fileType = FileType.GZipArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new LRZipArchive from the given file
|
/// Create a new LRZipArchive 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 as an archive</param>
|
||||||
public LRZipArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public LRZipArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.LRZipArchive;
|
_fileType = FileType.LRZipArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new LZ4Archive from the given file
|
/// Create a new LZ4Archive 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 as an archive</param>
|
||||||
public LZ4Archive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public LZ4Archive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.LZ4Archive;
|
_fileType = FileType.LZ4Archive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public RarArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public RarArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.RarArchive;
|
_fileType = FileType.RarArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public SevenZipArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public SevenZipArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.SevenZipArchive;
|
_fileType = FileType.SevenZipArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public TapeArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public TapeArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.TapeArchive;
|
_fileType = FileType.TapeArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public TorrentZipArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public TorrentZipArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.ZipArchive;
|
_fileType = FileType.ZipArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">Name of the file to use as an archive</param>
|
/// <param name="filename">Name of the file to use as an archive</param>
|
||||||
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
/// <param name="read">True for opening file as read, false for opening file as write</param>
|
||||||
public XZArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public XZArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.XZArchive;
|
_fileType = FileType.XZArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new ZPAQArchive from the given file
|
/// Create a new ZPAQArchive 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 as an archive</param>
|
||||||
public ZPAQArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public ZPAQArchive(string filename, bool getHashes = false)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.ZPAQArchive;
|
_fileType = FileType.ZPAQArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create a new ZstdArchive from the given file
|
/// Create a new ZstdArchive 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 as an archive</param>
|
||||||
public ZstdArchive(string filename)
|
/// <param name="getHashes">True if hashes for this file should be calculated, false otherwise (default)</param>
|
||||||
: base(filename)
|
public ZstdArchive(string filename, bool getHashes)
|
||||||
|
: base(filename, getHashes)
|
||||||
{
|
{
|
||||||
_fileType = FileType.ZstdArchive;
|
_fileType = FileType.ZstdArchive;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user