From f9d6fce3bddd0970300a33b5e76959879e91b0e2 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 23 Mar 2021 13:35:12 -0700 Subject: [PATCH] Reduce boilerplate for directory checks --- BurnOutSharp/IPathCheck.cs | 3 +-- BurnOutSharp/ProtectionType/AACS.cs | 5 ++--- BurnOutSharp/ProtectionType/AlphaDVD.cs | 5 ++--- BurnOutSharp/ProtectionType/BDPlus.cs | 5 ++--- BurnOutSharp/ProtectionType/Bitpool.cs | 5 ++--- BurnOutSharp/ProtectionType/ByteShield.cs | 5 ++--- BurnOutSharp/ProtectionType/CDCops.cs | 5 ++--- BurnOutSharp/ProtectionType/CDLock.cs | 5 ++--- BurnOutSharp/ProtectionType/CDProtector.cs | 5 ++--- BurnOutSharp/ProtectionType/CDX.cs | 5 ++--- .../ProtectionType/CactusDataShield.cs | 5 ++--- BurnOutSharp/ProtectionType/CopyKiller.cs | 5 ++--- BurnOutSharp/ProtectionType/DVDCrypt.cs | 5 ++--- .../ProtectionType/DVDMoviePROTECT.cs | 4 ++-- BurnOutSharp/ProtectionType/DiscGuard.cs | 5 ++--- BurnOutSharp/ProtectionType/FreeLock.cs | 5 ++--- BurnOutSharp/ProtectionType/GFWL.cs | 22 ++++++++++--------- .../ProtectionType/HexalockAutoLock.cs | 5 ++--- BurnOutSharp/ProtectionType/ImpulseReactor.cs | 5 ++--- BurnOutSharp/ProtectionType/IndyVCD.cs | 5 ++--- BurnOutSharp/ProtectionType/Key2AudioXS.cs | 5 ++--- BurnOutSharp/ProtectionType/LaserLock.cs | 5 ++--- BurnOutSharp/ProtectionType/MediaCloQ.cs | 5 ++--- BurnOutSharp/ProtectionType/MediaMaxCD3.cs | 5 ++--- BurnOutSharp/ProtectionType/Origin.cs | 5 ++--- .../ProtectionType/ProtectDVDVideo.cs | 4 ++-- BurnOutSharp/ProtectionType/SafeCast.cs | 5 ++--- BurnOutSharp/ProtectionType/SafeDisc.cs | 6 ++--- BurnOutSharp/ProtectionType/SafeDiscLite.cs | 5 ++--- BurnOutSharp/ProtectionType/SafeLock.cs | 5 ++--- BurnOutSharp/ProtectionType/SecuROM.cs | 5 ++--- BurnOutSharp/ProtectionType/SmartE.cs | 5 ++--- BurnOutSharp/ProtectionType/SoftLock.cs | 5 ++--- BurnOutSharp/ProtectionType/SolidShield.cs | 5 ++--- BurnOutSharp/ProtectionType/StarForce.cs | 5 ++--- BurnOutSharp/ProtectionType/Steam.cs | 5 ++--- .../ProtectionType/TZCopyProtector.cs | 5 ++--- BurnOutSharp/ProtectionType/Tages.cs | 4 ++-- BurnOutSharp/ProtectionType/Uplay.cs | 5 ++--- .../ProtectionType/VOBProtectCDDVD.cs | 5 ++--- BurnOutSharp/ProtectionType/WTMCDProtect.cs | 5 ++--- BurnOutSharp/ProtectionType/Winlock.cs | 5 ++--- BurnOutSharp/ProtectionType/XCP.cs | 6 ++--- BurnOutSharp/ProtectionType/Zzxzz.cs | 5 ++--- BurnOutSharp/Scanner.cs | 6 ++--- 45 files changed, 102 insertions(+), 138 deletions(-) diff --git a/BurnOutSharp/IPathCheck.cs b/BurnOutSharp/IPathCheck.cs index ebaf6ef3..94e50d62 100644 --- a/BurnOutSharp/IPathCheck.cs +++ b/BurnOutSharp/IPathCheck.cs @@ -10,8 +10,7 @@ namespace BurnOutSharp /// Path to check for protection indicators /// Enumerable of strings representing files in a directory /// This can do some limited content checking as well, but it's suggested to use IContentCheck instead, if possible - /// TODO: This should return a dictionary of file to protection mappings instead of just a single string - string CheckDirectoryPath(string path, IEnumerable files); + List CheckDirectoryPath(string path, IEnumerable files); /// /// Check a file path for protections based on path name diff --git a/BurnOutSharp/ProtectionType/AACS.cs b/BurnOutSharp/ProtectionType/AACS.cs index 11ef64a1..37fe4eff 100644 --- a/BurnOutSharp/ProtectionType/AACS.cs +++ b/BurnOutSharp/ProtectionType/AACS.cs @@ -7,7 +7,7 @@ namespace BurnOutSharp.ProtectionType public class AACS : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -18,8 +18,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(Path.Combine("AACS", "MKBROM.AACS"), GetVersion, "AACS"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/AlphaDVD.cs b/BurnOutSharp/ProtectionType/AlphaDVD.cs index 42dfd9b5..fa4485b6 100644 --- a/BurnOutSharp/ProtectionType/AlphaDVD.cs +++ b/BurnOutSharp/ProtectionType/AlphaDVD.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class AlphaDVD : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("PlayDVD.exe", useEndsWith: true), "Alpha-DVD"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/BDPlus.cs b/BurnOutSharp/ProtectionType/BDPlus.cs index 9940a88e..9562c36f 100644 --- a/BurnOutSharp/ProtectionType/BDPlus.cs +++ b/BurnOutSharp/ProtectionType/BDPlus.cs @@ -9,7 +9,7 @@ namespace BurnOutSharp.ProtectionType public class BDPlus : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -20,8 +20,7 @@ namespace BurnOutSharp.ProtectionType }, GetVersion, "BD+"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Bitpool.cs b/BurnOutSharp/ProtectionType/Bitpool.cs index 60f0b94f..3212974a 100644 --- a/BurnOutSharp/ProtectionType/Bitpool.cs +++ b/BurnOutSharp/ProtectionType/Bitpool.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class Bitpool : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("bitpool.rsc", useEndsWith: true), "Bitpool"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/ByteShield.cs b/BurnOutSharp/ProtectionType/ByteShield.cs index f834969b..f2810ffb 100644 --- a/BurnOutSharp/ProtectionType/ByteShield.cs +++ b/BurnOutSharp/ProtectionType/ByteShield.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class ByteShield : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -14,8 +14,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch(".bbz", useEndsWith: true), "ByteShield"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs index dde22b00..b1379c4f 100644 --- a/BurnOutSharp/ProtectionType/CDCops.cs +++ b/BurnOutSharp/ProtectionType/CDCops.cs @@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Original had "CDCOPS.DLL" required and all the rest in a combined OR var matchers = new List @@ -42,8 +42,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch(".QZ_", useEndsWith: true), "CD-Cops"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CDLock.cs b/BurnOutSharp/ProtectionType/CDLock.cs index b5216798..e838b2d1 100644 --- a/BurnOutSharp/ProtectionType/CDLock.cs +++ b/BurnOutSharp/ProtectionType/CDLock.cs @@ -27,15 +27,14 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch(".AFP", useEndsWith: true), "CD-Lock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CDProtector.cs b/BurnOutSharp/ProtectionType/CDProtector.cs index 7734a077..57a3a9d4 100644 --- a/BurnOutSharp/ProtectionType/CDProtector.cs +++ b/BurnOutSharp/ProtectionType/CDProtector.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class CDProtector : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -17,8 +17,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("_cdp32.dll", useEndsWith: true), "CD-Protector"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CDX.cs b/BurnOutSharp/ProtectionType/CDX.cs index 41f1bc95..76a9b70c 100644 --- a/BurnOutSharp/ProtectionType/CDX.cs +++ b/BurnOutSharp/ProtectionType/CDX.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class CDX : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -16,8 +16,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("CHKCDXNT.DLL", useEndsWith: true), "CD-X"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CactusDataShield.cs b/BurnOutSharp/ProtectionType/CactusDataShield.cs index 8920d887..6ab9a9c5 100644 --- a/BurnOutSharp/ProtectionType/CactusDataShield.cs +++ b/BurnOutSharp/ProtectionType/CactusDataShield.cs @@ -31,7 +31,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -43,8 +43,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch(".cds", useEndsWith: true), GetVersion, "Cactus Data Shield"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/CopyKiller.cs b/BurnOutSharp/ProtectionType/CopyKiller.cs index 93423969..e9af76e8 100644 --- a/BurnOutSharp/ProtectionType/CopyKiller.cs +++ b/BurnOutSharp/ProtectionType/CopyKiller.cs @@ -25,7 +25,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: The following checks are overly broad and should be refined var matchers = new List @@ -33,8 +33,7 @@ namespace BurnOutSharp.ProtectionType //new PathMatchSet(new PathMatch("Autorun.dat", useEndsWith: true), "CopyKiller"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/DVDCrypt.cs b/BurnOutSharp/ProtectionType/DVDCrypt.cs index 9c80ade5..776ff8bc 100644 --- a/BurnOutSharp/ProtectionType/DVDCrypt.cs +++ b/BurnOutSharp/ProtectionType/DVDCrypt.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class DVDCrypt : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("DvdCrypt.pdb", useEndsWith: true), "DVD Crypt"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs index 11651210..0d0459ff 100644 --- a/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs +++ b/BurnOutSharp/ProtectionType/DVDMoviePROTECT.cs @@ -8,7 +8,7 @@ namespace BurnOutSharp.ProtectionType public class DVDMoviePROTECT : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { @@ -18,7 +18,7 @@ namespace BurnOutSharp.ProtectionType FileInfo bupfile = new FileInfo(bupfiles[i]); FileInfo ifofile = new FileInfo(bupfile.DirectoryName + "\\" + bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo"); if (bupfile.Length != ifofile.Length) - return "DVD-Movie-PROTECT"; ; + return new List() { "DVD-Movie-PROTECT" }; } } diff --git a/BurnOutSharp/ProtectionType/DiscGuard.cs b/BurnOutSharp/ProtectionType/DiscGuard.cs index d0b72e4f..076491dd 100644 --- a/BurnOutSharp/ProtectionType/DiscGuard.cs +++ b/BurnOutSharp/ProtectionType/DiscGuard.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class DiscGuard : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -18,8 +18,7 @@ namespace BurnOutSharp.ProtectionType }, "DiscGuard"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: false); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: false); } /// diff --git a/BurnOutSharp/ProtectionType/FreeLock.cs b/BurnOutSharp/ProtectionType/FreeLock.cs index 906de789..2f44e46d 100644 --- a/BurnOutSharp/ProtectionType/FreeLock.cs +++ b/BurnOutSharp/ProtectionType/FreeLock.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class FreeLock : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("FREELOCK.IMG", useEndsWith: true), "FreeLock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index 00b0b41c..83d4f1e3 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -5,28 +5,30 @@ namespace BurnOutSharp.ProtectionType { public class GFWL : IContentCheck, IPathCheck { + /// + /// Set of all ContentMatchSets for this protection + /// + private static List contentMatchers = new List + { + // xlive.dll + new ContentMatchSet(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows - Live"), + }; + /// public string CheckContents(string file, byte[] fileContent, bool includePosition = false) { - var matchers = new List - { - // xlive.dll - new ContentMatchSet(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows - Live"), - }; - - return MatchUtil.GetFirstMatch(file, fileContent, matchers, includePosition); + return MatchUtil.GetFirstMatch(file, fileContent, contentMatchers, includePosition); } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("XLiveRedist.msi", useEndsWith: true), "Games for Windows - Live"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs index 22642f00..88bad64b 100644 --- a/BurnOutSharp/ProtectionType/HexalockAutoLock.cs +++ b/BurnOutSharp/ProtectionType/HexalockAutoLock.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class HexalockAutoLock : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -17,8 +17,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("MFIMP.DLL", useEndsWith: true), "Hexalock AutoLock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index c1f9322b..d8b9dd1c 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -48,15 +48,14 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetFileVersion, "Impulse Reactor"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/IndyVCD.cs b/BurnOutSharp/ProtectionType/IndyVCD.cs index e8381736..3fc6f2ca 100644 --- a/BurnOutSharp/ProtectionType/IndyVCD.cs +++ b/BurnOutSharp/ProtectionType/IndyVCD.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class IndyVCD : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -15,8 +15,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("INDYMP3.idt", useEndsWith: true), "IndyVCD"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Key2AudioXS.cs b/BurnOutSharp/ProtectionType/Key2AudioXS.cs index 7ef86d1f..639e371d 100644 --- a/BurnOutSharp/ProtectionType/Key2AudioXS.cs +++ b/BurnOutSharp/ProtectionType/Key2AudioXS.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class Key2AudioXS : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -15,8 +15,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("SDKHM.DLL", useEndsWith: true), "key2AudioXS"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs index 6bbe5839..9d181d9a 100644 --- a/BurnOutSharp/ProtectionType/LaserLock.cs +++ b/BurnOutSharp/ProtectionType/LaserLock.cs @@ -65,7 +65,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -80,8 +80,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("laserlok.011", useEndsWith: true), "LaserLock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/MediaCloQ.cs b/BurnOutSharp/ProtectionType/MediaCloQ.cs index fc2a6000..21a425d2 100644 --- a/BurnOutSharp/ProtectionType/MediaCloQ.cs +++ b/BurnOutSharp/ProtectionType/MediaCloQ.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class MediaCloQ : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("sunncomm.ico", useEndsWith: true), "MediaCloQ"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs index 370e2842..4cf24dba 100644 --- a/BurnOutSharp/ProtectionType/MediaMaxCD3.cs +++ b/BurnOutSharp/ProtectionType/MediaMaxCD3.cs @@ -28,15 +28,14 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("LaunchCd.exe", useEndsWith: true), "MediaMax CD-3"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs index 9a4e4346..5534ee87 100644 --- a/BurnOutSharp/ProtectionType/Origin.cs +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -21,15 +21,14 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs index a52727bb..fb2a9267 100644 --- a/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs +++ b/BurnOutSharp/ProtectionType/ProtectDVDVideo.cs @@ -8,7 +8,7 @@ namespace BurnOutSharp.ProtectionType public class ProtectDVDVideo : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { if (Directory.Exists(Path.Combine(path, "VIDEO_TS"))) { @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType { FileInfo ifofile = new FileInfo(ifofiles[i]); if (ifofile.Length == 0) - return "Protect DVD-Video"; + return new List() { "Protect DVD-Video" }; } } diff --git a/BurnOutSharp/ProtectionType/SafeCast.cs b/BurnOutSharp/ProtectionType/SafeCast.cs index 2035fb90..ca609f2a 100644 --- a/BurnOutSharp/ProtectionType/SafeCast.cs +++ b/BurnOutSharp/ProtectionType/SafeCast.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class SafeCast : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("cdac11ba.exe", useEndsWith: true), "SafeCast"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index b6eb4456..766454c5 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -61,7 +61,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { List protections = new List(); @@ -85,11 +85,11 @@ namespace BurnOutSharp.ProtectionType { protections.Add("SafeDisc for Macintosh"); } - + if (protections.Count == 0) return null; else - return string.Join(", ", protections); + return protections; } /// diff --git a/BurnOutSharp/ProtectionType/SafeDiscLite.cs b/BurnOutSharp/ProtectionType/SafeDiscLite.cs index cce1ab50..7a6c96b0 100644 --- a/BurnOutSharp/ProtectionType/SafeDiscLite.cs +++ b/BurnOutSharp/ProtectionType/SafeDiscLite.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class SafeDiscLite : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("00000001.LT1", useEndsWith: true), "SafeDisc Lite"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SafeLock.cs b/BurnOutSharp/ProtectionType/SafeLock.cs index 0c14b02b..1b0e9945 100644 --- a/BurnOutSharp/ProtectionType/SafeLock.cs +++ b/BurnOutSharp/ProtectionType/SafeLock.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -31,8 +31,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("SafeLock.128", useEndsWith: true), "SafeLock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 57970fa3..19848346 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -51,7 +51,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -68,8 +68,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("SINTFNT.DLL", useEndsWith: true), "SecuROM New"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SmartE.cs b/BurnOutSharp/ProtectionType/SmartE.cs index 13b1ee4f..ffbe7a78 100644 --- a/BurnOutSharp/ProtectionType/SmartE.cs +++ b/BurnOutSharp/ProtectionType/SmartE.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -30,8 +30,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("00002.TMP", useEndsWith: true), "SmartE"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SoftLock.cs b/BurnOutSharp/ProtectionType/SoftLock.cs index da864d83..1dd5dcde 100644 --- a/BurnOutSharp/ProtectionType/SoftLock.cs +++ b/BurnOutSharp/ProtectionType/SoftLock.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class SoftLock : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -15,8 +15,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("SOFTLOCKC.dat", useEndsWith: true), "SoftLock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index ed5d82ce..2eaeeb02 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -86,7 +86,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -97,8 +97,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("c11prot.dll", useEndsWith: true), "SolidShield"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index 2a933e03..874ffe0f 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -120,7 +120,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -129,8 +129,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("protect.exe", useEndsWith: true), "StarForce"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs index 2cca9511..bd981cde 100644 --- a/BurnOutSharp/ProtectionType/Steam.cs +++ b/BurnOutSharp/ProtectionType/Steam.cs @@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType public class Steam : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -17,8 +17,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("SteamSetup.exe", useEndsWith: true), "Steam"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/TZCopyProtector.cs b/BurnOutSharp/ProtectionType/TZCopyProtector.cs index 98b7b659..7226d523 100644 --- a/BurnOutSharp/ProtectionType/TZCopyProtector.cs +++ b/BurnOutSharp/ProtectionType/TZCopyProtector.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class TZCopyProtector : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("_742893.016", useEndsWith: true), "TZCopyProtector"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index f5c03a7b..36f2996e 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -42,7 +42,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { List protections = new List(); @@ -71,7 +71,7 @@ namespace BurnOutSharp.ProtectionType if (protections.Count == 0) return null; else - return string.Join(", ", protections); + return protections; } /// diff --git a/BurnOutSharp/ProtectionType/Uplay.cs b/BurnOutSharp/ProtectionType/Uplay.cs index c548d48a..5dc01d32 100644 --- a/BurnOutSharp/ProtectionType/Uplay.cs +++ b/BurnOutSharp/ProtectionType/Uplay.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class Uplay : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("UplayInstaller.exe", useEndsWith: true), "Uplay"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs index 3ccd7f79..375f907a 100644 --- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs +++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs @@ -36,15 +36,14 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("VOB-PCD.KEY", useEndsWith: true), "VOB ProtectCD/DVD"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs index 4e157873..f9fa01a5 100644 --- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND var matchers = new List @@ -32,8 +32,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet(new PathMatch("Viewer.exe", useEndsWith: true), "WTM CD Protect"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/Winlock.cs b/BurnOutSharp/ProtectionType/Winlock.cs index c586561d..4f9bfaf0 100644 --- a/BurnOutSharp/ProtectionType/Winlock.cs +++ b/BurnOutSharp/ProtectionType/Winlock.cs @@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType public class Winlock : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { new PathMatchSet(new PathMatch("WinLock.PSX", useEndsWith: true), "Winlock"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/ProtectionType/XCP.cs b/BurnOutSharp/ProtectionType/XCP.cs index d75341ee..85dd885d 100644 --- a/BurnOutSharp/ProtectionType/XCP.cs +++ b/BurnOutSharp/ProtectionType/XCP.cs @@ -40,7 +40,7 @@ namespace BurnOutSharp.ProtectionType } /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { // TODO: Verify if these are OR or AND if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)) @@ -52,10 +52,10 @@ namespace BurnOutSharp.ProtectionType { string xcpVersion = GetDatVersion(versionDatPath); if (!string.IsNullOrWhiteSpace(xcpVersion)) - return xcpVersion; + return new List() { xcpVersion }; } - return "XCP"; + return new List() { "XCP" }; } return null; diff --git a/BurnOutSharp/ProtectionType/Zzxzz.cs b/BurnOutSharp/ProtectionType/Zzxzz.cs index 6b4c98d6..40374af0 100644 --- a/BurnOutSharp/ProtectionType/Zzxzz.cs +++ b/BurnOutSharp/ProtectionType/Zzxzz.cs @@ -7,7 +7,7 @@ namespace BurnOutSharp.ProtectionType public class Zzxzz : IPathCheck { /// - public string CheckDirectoryPath(string path, IEnumerable files) + public List CheckDirectoryPath(string path, IEnumerable files) { var matchers = new List { @@ -15,8 +15,7 @@ namespace BurnOutSharp.ProtectionType new PathMatchSet($"Zzxzz{Path.DirectorySeparatorChar}", "Zzxzz"), }; - var matches = MatchUtil.GetAllMatches(files, matchers, any: true); - return string.Join(", ", matches); + return MatchUtil.GetAllMatches(files, matchers, any: true); } /// diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 7fde7325..a8ae5996 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -189,9 +189,9 @@ namespace BurnOutSharp // Iterate through all path checks foreach (var pathCheckClass in pathCheckClasses) { - string protection = pathCheckClass.CheckDirectoryPath(path, files); - if (!string.IsNullOrWhiteSpace(protection)) - protections.Add(protection); + List protection = pathCheckClass.CheckDirectoryPath(path, files); + if (protection != null) + protections.AddRange(protection); } // Create and return the dictionary