diff --git a/BinaryObjectScanner.Test/ExtensionsTests.cs b/BinaryObjectScanner.Test/ExtensionsTests.cs index f285822c..633d1edc 100644 --- a/BinaryObjectScanner.Test/ExtensionsTests.cs +++ b/BinaryObjectScanner.Test/ExtensionsTests.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Xunit; namespace BinaryObjectScanner.Test @@ -33,300 +31,5 @@ namespace BinaryObjectScanner.Test } #endregion - - #region IterateWithAction - - [Fact] - public void IterateWithAction_EmptyEnumerable_Success() - { - List set = new List(); - Action action = (s) => s.ToLowerInvariant(); - - set.IterateWithAction(action); - Assert.Empty(set); - } - - [Fact] - public void IterateWithAction_EmptyAction_Success() - { - List set = ["a", "b", "c"]; - Action action = (s) => { }; - - set.IterateWithAction(action); - Assert.Equal(3, set.Count); - } - - [Fact] - public void IterateWithAction_Valid_Success() - { - List set = ["a", "b", "c"]; - List actual = new List(); - - Action action = (s) => - { - lock (actual) - { - actual.Add(s.ToUpperInvariant()); - } - }; - - set.IterateWithAction(action); - Assert.Equal(3, set.Count); - Assert.Equal(3, actual.Count); - } - - #endregion - - #region OptionalContains - - [Fact] - public void OptionalContains_NullStringNoComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_NullStringComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_EmptyStringNoComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_EmptyStringComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_NoMatchNoComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_NoMatchComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalContains_MatchesNoComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix); - Assert.True(actual); - } - - [Fact] - public void OptionalContains_MatchesComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalContains(prefix, StringComparison.OrdinalIgnoreCase); - Assert.True(actual); - } - - #endregion - - #region OptionalEquals - - [Fact] - public void OptionalEquals_NullStringNoComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_NullStringComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_EmptyStringNoComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_EmptyStringComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_NoMatchNoComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_NoMatchComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalEquals_MatchesNoComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix); - Assert.True(actual); - } - - [Fact] - public void OptionalEquals_MatchesComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalEquals(prefix, StringComparison.OrdinalIgnoreCase); - Assert.True(actual); - } - - #endregion - - #region OptionalStartsWith - - [Fact] - public void OptionalStartsWith_NullStringNoComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_NullStringComparison_False() - { - string? str = null; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_EmptyStringNoComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_EmptyStringComparison_False() - { - string? str = string.Empty; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_NoMatchNoComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_NoMatchComparison_False() - { - string? str = "postfix"; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); - Assert.False(actual); - } - - [Fact] - public void OptionalStartsWith_MatchesNoComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix); - Assert.True(actual); - } - - [Fact] - public void OptionalStartsWith_MatchesComparison_True() - { - string? str = "prefix"; - string prefix = "prefix"; - - bool actual = str.OptionalStartsWith(prefix, StringComparison.OrdinalIgnoreCase); - Assert.True(actual); - } - - #endregion } } \ No newline at end of file diff --git a/BinaryObjectScanner/Extensions.cs b/BinaryObjectScanner/Extensions.cs index 9641d4a2..3fcb091d 100644 --- a/BinaryObjectScanner/Extensions.cs +++ b/BinaryObjectScanner/Extensions.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; using System.IO; namespace BinaryObjectScanner { - // TODO: Clean this up once IO is updated internal static class Extensions { /// @@ -31,80 +28,5 @@ namespace BinaryObjectScanner return -1; } } - - /// - /// Wrap iterating through an enumerable with an action - /// - /// - /// .NET Frameworks 2.0 and 3.5 process in series. - /// .NET Frameworks 4.0 onward process in parallel. - /// - public static void IterateWithAction(this IEnumerable source, Action action) - { -#if NET20 || NET35 - foreach (var item in source) - { - action(item); - } -#else - System.Threading.Tasks.Parallel.ForEach(source, action); -#endif - } - - /// - public static bool OptionalContains(this string? self, string value) - => OptionalContains(self, value, StringComparison.Ordinal); - - /// - public static bool OptionalContains(this string? self, string value, StringComparison comparisonType) - { - if (self == null) - return false; - -#if NETFRAMEWORK || NETSTANDARD2_0 - return self.Contains(value); -#else - return self.Contains(value, comparisonType); -#endif - } - - /// - public static bool OptionalEndsWith(this string? self, string value) - => OptionalEndsWith(self, value, StringComparison.Ordinal); - - /// - public static bool OptionalEndsWith(this string? self, string value, StringComparison comparisonType) - { - if (self == null) - return false; - - return self.EndsWith(value, comparisonType); - } - - /// - public static bool OptionalEquals(this string? self, string value) - => OptionalEquals(self, value, StringComparison.Ordinal); - - /// - public static bool OptionalEquals(this string? self, string value, StringComparison comparisonType) - { - if (self == null) - return false; - - return self.Equals(value, comparisonType); - } - - /// - public static bool OptionalStartsWith(this string? self, string value) - => OptionalStartsWith(self, value, StringComparison.Ordinal); - - /// - public static bool OptionalStartsWith(this string? self, string value, StringComparison comparisonType) - { - if (self == null) - return false; - - return self.StartsWith(value, comparisonType); - } } } \ No newline at end of file diff --git a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs index bdc02532..b07c7772 100644 --- a/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs +++ b/BinaryObjectScanner/Packer/AutoPlayMediaStudio.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/GPInstall.cs b/BinaryObjectScanner/Packer/GPInstall.cs index 7e24a119..e6385dbf 100644 --- a/BinaryObjectScanner/Packer/GPInstall.cs +++ b/BinaryObjectScanner/Packer/GPInstall.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/GenteeInstaller.cs b/BinaryObjectScanner/Packer/GenteeInstaller.cs index 90ba7c0f..b50ceeb5 100644 --- a/BinaryObjectScanner/Packer/GenteeInstaller.cs +++ b/BinaryObjectScanner/Packer/GenteeInstaller.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/GkWareSFX.cs b/BinaryObjectScanner/Packer/GkWareSFX.cs index a5341617..ef8aab98 100644 --- a/BinaryObjectScanner/Packer/GkWareSFX.cs +++ b/BinaryObjectScanner/Packer/GkWareSFX.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/InstallAnywhere.cs b/BinaryObjectScanner/Packer/InstallAnywhere.cs index 38d03312..78fb33f9 100644 --- a/BinaryObjectScanner/Packer/InstallAnywhere.cs +++ b/BinaryObjectScanner/Packer/InstallAnywhere.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/IntelInstallationFramework.cs b/BinaryObjectScanner/Packer/IntelInstallationFramework.cs index aa2f708c..b6f63154 100644 --- a/BinaryObjectScanner/Packer/IntelInstallationFramework.cs +++ b/BinaryObjectScanner/Packer/IntelInstallationFramework.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs b/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs index e02d2637..2999e294 100644 --- a/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs +++ b/BinaryObjectScanner/Packer/MicrosoftCABSFX.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/NSIS.cs b/BinaryObjectScanner/Packer/NSIS.cs index 0f919a13..c2918fd5 100644 --- a/BinaryObjectScanner/Packer/NSIS.cs +++ b/BinaryObjectScanner/Packer/NSIS.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/SetupFactory.cs b/BinaryObjectScanner/Packer/SetupFactory.cs index 6bfe46f4..9fd1ea8c 100644 --- a/BinaryObjectScanner/Packer/SetupFactory.cs +++ b/BinaryObjectScanner/Packer/SetupFactory.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/SevenZipSFX.cs b/BinaryObjectScanner/Packer/SevenZipSFX.cs index cd0e401e..dd43181b 100644 --- a/BinaryObjectScanner/Packer/SevenZipSFX.cs +++ b/BinaryObjectScanner/Packer/SevenZipSFX.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/SmartInstallMaker.cs b/BinaryObjectScanner/Packer/SmartInstallMaker.cs index 57bb292c..f5a396d1 100644 --- a/BinaryObjectScanner/Packer/SmartInstallMaker.cs +++ b/BinaryObjectScanner/Packer/SmartInstallMaker.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/SpoonInstaller.cs b/BinaryObjectScanner/Packer/SpoonInstaller.cs index 56b7a6a8..5d350e08 100644 --- a/BinaryObjectScanner/Packer/SpoonInstaller.cs +++ b/BinaryObjectScanner/Packer/SpoonInstaller.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Packer/WinRARSFX.cs b/BinaryObjectScanner/Packer/WinRARSFX.cs index 751ebd7f..e9b67821 100644 --- a/BinaryObjectScanner/Packer/WinRARSFX.cs +++ b/BinaryObjectScanner/Packer/WinRARSFX.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Packer diff --git a/BinaryObjectScanner/Protection/Armadillo.cs b/BinaryObjectScanner/Protection/Armadillo.cs index 61b16860..b244ef7c 100644 --- a/BinaryObjectScanner/Protection/Armadillo.cs +++ b/BinaryObjectScanner/Protection/Armadillo.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/ByteShield.cs b/BinaryObjectScanner/Protection/ByteShield.cs index 656f7dae..69331c64 100644 --- a/BinaryObjectScanner/Protection/ByteShield.cs +++ b/BinaryObjectScanner/Protection/ByteShield.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/CDCheck.cs b/BinaryObjectScanner/Protection/CDCheck.cs index 3e1f9162..0bce1de2 100644 --- a/BinaryObjectScanner/Protection/CDCheck.cs +++ b/BinaryObjectScanner/Protection/CDCheck.cs @@ -1,4 +1,5 @@ using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/CDGuard.cs b/BinaryObjectScanner/Protection/CDGuard.cs index 6904a094..5bdae6e0 100644 --- a/BinaryObjectScanner/Protection/CDGuard.cs +++ b/BinaryObjectScanner/Protection/CDGuard.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/CDKey.cs b/BinaryObjectScanner/Protection/CDKey.cs index 8dbf6af2..22f9a631 100644 --- a/BinaryObjectScanner/Protection/CDKey.cs +++ b/BinaryObjectScanner/Protection/CDKey.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs index ad41545c..3bccbf0a 100644 --- a/BinaryObjectScanner/Protection/CenegaProtectDVD.cs +++ b/BinaryObjectScanner/Protection/CenegaProtectDVD.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Channelware.cs b/BinaryObjectScanner/Protection/Channelware.cs index 263b0124..29f4ed34 100644 --- a/BinaryObjectScanner/Protection/Channelware.cs +++ b/BinaryObjectScanner/Protection/Channelware.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs index 91932965..b3ebad5c 100644 --- a/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs +++ b/BinaryObjectScanner/Protection/ChosenBytesCodeLock.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/CopyKiller.cs b/BinaryObjectScanner/Protection/CopyKiller.cs index 40211748..d610ee0f 100644 --- a/BinaryObjectScanner/Protection/CopyKiller.cs +++ b/BinaryObjectScanner/Protection/CopyKiller.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/CrypKey.cs b/BinaryObjectScanner/Protection/CrypKey.cs index 8be49176..f8fcf68a 100644 --- a/BinaryObjectScanner/Protection/CrypKey.cs +++ b/BinaryObjectScanner/Protection/CrypKey.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs index 805c2b34..5b5e560e 100644 --- a/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs +++ b/BinaryObjectScanner/Protection/DVDMoviePROTECT.cs @@ -23,8 +23,8 @@ namespace BinaryObjectScanner.Protection if (bupfile.DirectoryName == null) continue; - var ifofile = new FileInfo(Path.Combine(bupfile.DirectoryName, bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo")); - if (bupfile.Length != ifofile.Length) + string ifofile = Path.Combine(bupfile.DirectoryName, bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo"); + if (bupfile.Length != ifofile.FileSize()) { protections.Add("DVD-Movie-PROTECT (Unconfirmed - Please report to us on Github)"); break; diff --git a/BinaryObjectScanner/Protection/Denuvo.cs b/BinaryObjectScanner/Protection/Denuvo.cs index bc209af2..74fdc4cf 100644 --- a/BinaryObjectScanner/Protection/Denuvo.cs +++ b/BinaryObjectScanner/Protection/Denuvo.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/DigiGuard.cs b/BinaryObjectScanner/Protection/DigiGuard.cs index 8fee3dd1..004807d1 100644 --- a/BinaryObjectScanner/Protection/DigiGuard.cs +++ b/BinaryObjectScanner/Protection/DigiGuard.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/DiscGuard.cs b/BinaryObjectScanner/Protection/DiscGuard.cs index 117cf11a..0c3fadf2 100644 --- a/BinaryObjectScanner/Protection/DiscGuard.cs +++ b/BinaryObjectScanner/Protection/DiscGuard.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/ElectronicArts.cs b/BinaryObjectScanner/Protection/ElectronicArts.cs index eecad80b..1af7eb6c 100644 --- a/BinaryObjectScanner/Protection/ElectronicArts.cs +++ b/BinaryObjectScanner/Protection/ElectronicArts.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/GFWL.cs b/BinaryObjectScanner/Protection/GFWL.cs index e15bd539..b7809415 100644 --- a/BinaryObjectScanner/Protection/GFWL.cs +++ b/BinaryObjectScanner/Protection/GFWL.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/HexalockAutoLock.cs b/BinaryObjectScanner/Protection/HexalockAutoLock.cs index 58b2e04d..be94ce27 100644 --- a/BinaryObjectScanner/Protection/HexalockAutoLock.cs +++ b/BinaryObjectScanner/Protection/HexalockAutoLock.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/ImpulseReactor.cs b/BinaryObjectScanner/Protection/ImpulseReactor.cs index 54f60d23..945e7003 100644 --- a/BinaryObjectScanner/Protection/ImpulseReactor.cs +++ b/BinaryObjectScanner/Protection/ImpulseReactor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/KalypsoLauncher.cs b/BinaryObjectScanner/Protection/KalypsoLauncher.cs index d944dda2..a38654e1 100644 --- a/BinaryObjectScanner/Protection/KalypsoLauncher.cs +++ b/BinaryObjectScanner/Protection/KalypsoLauncher.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/LabelGate.cs b/BinaryObjectScanner/Protection/LabelGate.cs index e5c66c45..fabb34d4 100644 --- a/BinaryObjectScanner/Protection/LabelGate.cs +++ b/BinaryObjectScanner/Protection/LabelGate.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/MGIRegistration.cs b/BinaryObjectScanner/Protection/MGIRegistration.cs index 45ec6684..f9837d59 100644 --- a/BinaryObjectScanner/Protection/MGIRegistration.cs +++ b/BinaryObjectScanner/Protection/MGIRegistration.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs index c43268f6..58a188a1 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CDilla.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CDilla.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs index b29b6f80..b1fad9ee 100644 --- a/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs +++ b/BinaryObjectScanner/Protection/Macrovision.CactusDataShield.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs index e519104d..eee52120 100644 --- a/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs +++ b/BinaryObjectScanner/Protection/Macrovision.FLEXnet.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs index 42415b58..00c4a63d 100644 --- a/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs +++ b/BinaryObjectScanner/Protection/Macrovision.RipGuard.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using SabreTools.Hashing; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs index 6c7e706b..928f11a2 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeCast.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs index 2eba649b..a84191be 100644 --- a/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs +++ b/BinaryObjectScanner/Protection/Macrovision.SafeDisc.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using SabreTools.Hashing; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; @@ -800,8 +801,7 @@ namespace BinaryObjectScanner.Protection if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString)) return string.Empty; - var fi = new FileInfo(firstMatchedString); - return fi.Length switch + return firstMatchedString.FileSize() switch { // File size of "dplayerx.dll" and others is a commonly used indicator of SafeDisc version, though it has been found to not be completely consistent. // Checks for versions 1.2X have been commented out, due to these versions already being detected via more accurate checks. diff --git a/BinaryObjectScanner/Protection/Macrovision.cs b/BinaryObjectScanner/Protection/Macrovision.cs index ef2de13f..21e97fb0 100644 --- a/BinaryObjectScanner/Protection/Macrovision.cs +++ b/BinaryObjectScanner/Protection/Macrovision.cs @@ -276,8 +276,7 @@ namespace BinaryObjectScanner.Protection // This file is present in most, if not all, SafeDisc protected discs. It seems to have very consistent file sizes, only being found to use three different file sizes in it's entire run. // A rough estimate of the product and version can be gotten by checking the file size. // One filesize is known to overlap with both SafeDisc and CDS-300, and so is detected separately here. - var fi = new FileInfo(firstMatchedString); - return fi.Length switch + return firstMatchedString.FileSize() switch { // Found in Redump entries 37832 and 66005. 20 => "SafeDisc 1.00.025-1.41.001", @@ -298,8 +297,7 @@ namespace BinaryObjectScanner.Protection if (string.IsNullOrEmpty(firstMatchedString) || !File.Exists(firstMatchedString)) return string.Empty; - var fi = new FileInfo(firstMatchedString); - return fi.Length switch + return firstMatchedString.FileSize() switch { // Found in Redump entry 63488. 0 => "(Empty File)", diff --git a/BinaryObjectScanner/Protection/MediaCloQ.cs b/BinaryObjectScanner/Protection/MediaCloQ.cs index 4a57287e..67c5ac6d 100644 --- a/BinaryObjectScanner/Protection/MediaCloQ.cs +++ b/BinaryObjectScanner/Protection/MediaCloQ.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/MediaMax.cs b/BinaryObjectScanner/Protection/MediaMax.cs index 47f2a627..f44b145d 100644 --- a/BinaryObjectScanner/Protection/MediaMax.cs +++ b/BinaryObjectScanner/Protection/MediaMax.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/NProtect.cs b/BinaryObjectScanner/Protection/NProtect.cs index fba6f843..2de71f57 100644 --- a/BinaryObjectScanner/Protection/NProtect.cs +++ b/BinaryObjectScanner/Protection/NProtect.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/OnlineRegistration.cs b/BinaryObjectScanner/Protection/OnlineRegistration.cs index 7ee449c6..986d919f 100644 --- a/BinaryObjectScanner/Protection/OnlineRegistration.cs +++ b/BinaryObjectScanner/Protection/OnlineRegistration.cs @@ -1,5 +1,6 @@ using System; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Serialization.Wrappers; namespace BinaryObjectScanner.Protection diff --git a/BinaryObjectScanner/Protection/OpenMG.cs b/BinaryObjectScanner/Protection/OpenMG.cs index ee07757b..01e92f8c 100644 --- a/BinaryObjectScanner/Protection/OpenMG.cs +++ b/BinaryObjectScanner/Protection/OpenMG.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Origin.cs b/BinaryObjectScanner/Protection/Origin.cs index 3e45620e..61cb47cd 100644 --- a/BinaryObjectScanner/Protection/Origin.cs +++ b/BinaryObjectScanner/Protection/Origin.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/PlayJ.cs b/BinaryObjectScanner/Protection/PlayJ.cs index e835aeef..85efd194 100644 --- a/BinaryObjectScanner/Protection/PlayJ.cs +++ b/BinaryObjectScanner/Protection/PlayJ.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs index aac5398c..38aad2e0 100644 --- a/BinaryObjectScanner/Protection/ProtectDVDVideo.cs +++ b/BinaryObjectScanner/Protection/ProtectDVDVideo.cs @@ -19,8 +19,7 @@ namespace BinaryObjectScanner.Protection var ifofiles = files.FindAll(s => s.EndsWith(".ifo")); for (int i = 0; i < ifofiles.Count; i++) { - var ifofile = new FileInfo(ifofiles[i]); - if (ifofile.Length == 0) + if (ifofiles[i].FileSize() == 0) { protections.Add("Protect DVD-Video (Unconfirmed - Please report to us on Github)"); break; diff --git a/BinaryObjectScanner/Protection/RainbowSentinel.cs b/BinaryObjectScanner/Protection/RainbowSentinel.cs index c0faf598..7bfa4fd0 100644 --- a/BinaryObjectScanner/Protection/RainbowSentinel.cs +++ b/BinaryObjectScanner/Protection/RainbowSentinel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/RealArcade.cs b/BinaryObjectScanner/Protection/RealArcade.cs index f804e876..39db21fe 100644 --- a/BinaryObjectScanner/Protection/RealArcade.cs +++ b/BinaryObjectScanner/Protection/RealArcade.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/SmartE.cs b/BinaryObjectScanner/Protection/SmartE.cs index 5b6fd7c5..cb85f663 100644 --- a/BinaryObjectScanner/Protection/SmartE.cs +++ b/BinaryObjectScanner/Protection/SmartE.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/SoftLock.cs b/BinaryObjectScanner/Protection/SoftLock.cs index c051aec4..5a22dfe6 100644 --- a/BinaryObjectScanner/Protection/SoftLock.cs +++ b/BinaryObjectScanner/Protection/SoftLock.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/SolidShield.cs b/BinaryObjectScanner/Protection/SolidShield.cs index 4bacf76b..70de3482 100644 --- a/BinaryObjectScanner/Protection/SolidShield.cs +++ b/BinaryObjectScanner/Protection/SolidShield.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/StarForce.cs b/BinaryObjectScanner/Protection/StarForce.cs index 1109ec47..6682e4bc 100644 --- a/BinaryObjectScanner/Protection/StarForce.cs +++ b/BinaryObjectScanner/Protection/StarForce.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Steam.cs b/BinaryObjectScanner/Protection/Steam.cs index ffef425a..594fb34e 100644 --- a/BinaryObjectScanner/Protection/Steam.cs +++ b/BinaryObjectScanner/Protection/Steam.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Tages.cs b/BinaryObjectScanner/Protection/Tages.cs index eea4c726..c83f9073 100644 --- a/BinaryObjectScanner/Protection/Tages.cs +++ b/BinaryObjectScanner/Protection/Tages.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Content; using SabreTools.Matching.Paths; diff --git a/BinaryObjectScanner/Protection/UnilocSoftAnchor.cs b/BinaryObjectScanner/Protection/UnilocSoftAnchor.cs index d069af82..bdd849c6 100644 --- a/BinaryObjectScanner/Protection/UnilocSoftAnchor.cs +++ b/BinaryObjectScanner/Protection/UnilocSoftAnchor.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/Uplay.cs b/BinaryObjectScanner/Protection/Uplay.cs index 35f1fe4f..56eb474d 100644 --- a/BinaryObjectScanner/Protection/Uplay.cs +++ b/BinaryObjectScanner/Protection/Uplay.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/WMDS.cs b/BinaryObjectScanner/Protection/WMDS.cs index 6581e541..479acdd2 100644 --- a/BinaryObjectScanner/Protection/WMDS.cs +++ b/BinaryObjectScanner/Protection/WMDS.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers; diff --git a/BinaryObjectScanner/Protection/WTMCDProtect.cs b/BinaryObjectScanner/Protection/WTMCDProtect.cs index cd56bcaf..51f98074 100644 --- a/BinaryObjectScanner/Protection/WTMCDProtect.cs +++ b/BinaryObjectScanner/Protection/WTMCDProtect.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BinaryObjectScanner.Interfaces; +using SabreTools.IO.Extensions; using SabreTools.Matching; using SabreTools.Matching.Paths; using SabreTools.Serialization.Wrappers;