diff --git a/SabreTools.Library/FileTypes/BaseArchive.cs b/SabreTools.Library/FileTypes/BaseArchive.cs index bd1b7785..ba76c42c 100644 --- a/SabreTools.Library/FileTypes/BaseArchive.cs +++ b/SabreTools.Library/FileTypes/BaseArchive.cs @@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes /// Create a new Archive from the given file /// /// Name of the file to use as an archive - public BaseArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public BaseArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { } diff --git a/SabreTools.Library/FileTypes/BaseFile.cs b/SabreTools.Library/FileTypes/BaseFile.cs index 4520023c..d625639d 100644 --- a/SabreTools.Library/FileTypes/BaseFile.cs +++ b/SabreTools.Library/FileTypes/BaseFile.cs @@ -102,21 +102,26 @@ namespace SabreTools.Library.FileTypes /// Create a new BaseFile from the given file /// /// Name of the file to use - public BaseFile(string filename) + /// True if hashes for this file should be calculated (default), false otherwise + public BaseFile(string filename, bool getHashes = true) { this._filename = filename; - BaseFile temp = Utilities.GetFileInfo(_filename); - if (temp != null) + if (getHashes) { - 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; + 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; + } } } @@ -125,19 +130,28 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use /// Stream to populate information from - public BaseFile(string filename, Stream stream) + /// True if hashes for this file should be calculated (default), false otherwise + public BaseFile(string filename, Stream stream, bool getHashes = true) { - BaseFile temp = Utilities.GetStreamInfo(stream, stream.Length); - this._filename = 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; + + 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 diff --git a/SabreTools.Library/FileTypes/Folder.cs b/SabreTools.Library/FileTypes/Folder.cs index cf8e9ca1..bf75e549 100644 --- a/SabreTools.Library/FileTypes/Folder.cs +++ b/SabreTools.Library/FileTypes/Folder.cs @@ -50,8 +50,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public Folder(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public Folder(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.Folder; } diff --git a/SabreTools.Library/FileTypes/GZipArchive.cs b/SabreTools.Library/FileTypes/GZipArchive.cs index 1c33cc44..0c94acdb 100644 --- a/SabreTools.Library/FileTypes/GZipArchive.cs +++ b/SabreTools.Library/FileTypes/GZipArchive.cs @@ -45,8 +45,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public GZipArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public GZipArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.GZipArchive; } diff --git a/SabreTools.Library/FileTypes/LRZipArchive.cs b/SabreTools.Library/FileTypes/LRZipArchive.cs index 35b53a81..4ffb5c5b 100644 --- a/SabreTools.Library/FileTypes/LRZipArchive.cs +++ b/SabreTools.Library/FileTypes/LRZipArchive.cs @@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes /// Create a new LRZipArchive from the given file /// /// Name of the file to use as an archive - public LRZipArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public LRZipArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.LRZipArchive; } diff --git a/SabreTools.Library/FileTypes/LZ4Archive.cs b/SabreTools.Library/FileTypes/LZ4Archive.cs index 7d8ac92f..b307549a 100644 --- a/SabreTools.Library/FileTypes/LZ4Archive.cs +++ b/SabreTools.Library/FileTypes/LZ4Archive.cs @@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes /// Create a new LZ4Archive from the given file /// /// Name of the file to use as an archive - public LZ4Archive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public LZ4Archive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.LZ4Archive; } diff --git a/SabreTools.Library/FileTypes/RarArchive.cs b/SabreTools.Library/FileTypes/RarArchive.cs index c748de60..641066e4 100644 --- a/SabreTools.Library/FileTypes/RarArchive.cs +++ b/SabreTools.Library/FileTypes/RarArchive.cs @@ -45,8 +45,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public RarArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public RarArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.RarArchive; } diff --git a/SabreTools.Library/FileTypes/SevenZipArchive.cs b/SabreTools.Library/FileTypes/SevenZipArchive.cs index 46622615..1d430afd 100644 --- a/SabreTools.Library/FileTypes/SevenZipArchive.cs +++ b/SabreTools.Library/FileTypes/SevenZipArchive.cs @@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public SevenZipArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public SevenZipArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.SevenZipArchive; } diff --git a/SabreTools.Library/FileTypes/TapeArchive.cs b/SabreTools.Library/FileTypes/TapeArchive.cs index 02d81f69..c93c52b0 100644 --- a/SabreTools.Library/FileTypes/TapeArchive.cs +++ b/SabreTools.Library/FileTypes/TapeArchive.cs @@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public TapeArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public TapeArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.TapeArchive; } diff --git a/SabreTools.Library/FileTypes/TorrentZipArchive.cs b/SabreTools.Library/FileTypes/TorrentZipArchive.cs index 77cbf1e2..a02173e2 100644 --- a/SabreTools.Library/FileTypes/TorrentZipArchive.cs +++ b/SabreTools.Library/FileTypes/TorrentZipArchive.cs @@ -44,8 +44,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public TorrentZipArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public TorrentZipArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.ZipArchive; } diff --git a/SabreTools.Library/FileTypes/XZArchive.cs b/SabreTools.Library/FileTypes/XZArchive.cs index 5e73c16b..f0ebd430 100644 --- a/SabreTools.Library/FileTypes/XZArchive.cs +++ b/SabreTools.Library/FileTypes/XZArchive.cs @@ -48,8 +48,9 @@ namespace SabreTools.Library.FileTypes /// /// Name of the file to use as an archive /// True for opening file as read, false for opening file as write - public XZArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public XZArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.XZArchive; } diff --git a/SabreTools.Library/FileTypes/ZPAQArchive.cs b/SabreTools.Library/FileTypes/ZPAQArchive.cs index 7fd012bf..6e34f189 100644 --- a/SabreTools.Library/FileTypes/ZPAQArchive.cs +++ b/SabreTools.Library/FileTypes/ZPAQArchive.cs @@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes /// Create a new ZPAQArchive from the given file /// /// Name of the file to use as an archive - public ZPAQArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public ZPAQArchive(string filename, bool getHashes = false) + : base(filename, getHashes) { _fileType = FileType.ZPAQArchive; } diff --git a/SabreTools.Library/FileTypes/ZstdArchive.cs b/SabreTools.Library/FileTypes/ZstdArchive.cs index 09343096..ba68aa0a 100644 --- a/SabreTools.Library/FileTypes/ZstdArchive.cs +++ b/SabreTools.Library/FileTypes/ZstdArchive.cs @@ -34,8 +34,9 @@ namespace SabreTools.Library.FileTypes /// Create a new ZstdArchive from the given file /// /// Name of the file to use as an archive - public ZstdArchive(string filename) - : base(filename) + /// True if hashes for this file should be calculated, false otherwise (default) + public ZstdArchive(string filename, bool getHashes) + : base(filename, getHashes) { _fileType = FileType.ZstdArchive; }