Reduce boilerplate for directory checks

This commit is contained in:
Matt Nadareski
2021-03-23 13:35:12 -07:00
parent aa83896963
commit f9d6fce3bd
45 changed files with 102 additions and 138 deletions

View File

@@ -10,8 +10,7 @@ namespace BurnOutSharp
/// <param name="path">Path to check for protection indicators</param>
/// <param name="files">Enumerable of strings representing files in a directory</param>
/// <remarks>This can do some limited content checking as well, but it's suggested to use IContentCheck instead, if possible</remarks>
/// TODO: This should return a dictionary of file to protection mappings instead of just a single string
string CheckDirectoryPath(string path, IEnumerable<string> files);
List<string> CheckDirectoryPath(string path, IEnumerable<string> files);
/// <summary>
/// Check a file path for protections based on path name

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ProtectionType
public class AACS : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class AlphaDVD : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -9,7 +9,7 @@ namespace BurnOutSharp.ProtectionType
public class BDPlus : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class Bitpool : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class ByteShield : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Original had "CDCOPS.DLL" required and all the rest in a combined OR
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -27,15 +27,14 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class CDProtector : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class CDX : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -31,7 +31,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -25,7 +25,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: The following checks are overly broad and should be refined
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class DVDCrypt : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ProtectionType
public class DVDMoviePROTECT : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> 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<string>() { "DVD-Movie-PROTECT" };
}
}

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class DiscGuard : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class FreeLock : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -5,28 +5,30 @@ namespace BurnOutSharp.ProtectionType
{
public class GFWL : IContentCheck, IPathCheck
{
/// <summary>
/// Set of all ContentMatchSets for this protection
/// </summary>
private static List<ContentMatchSet> contentMatchers = new List<ContentMatchSet>
{
// xlive.dll
new ContentMatchSet(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows - Live"),
};
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
var matchers = new List<ContentMatchSet>
{
// 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);
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class HexalockAutoLock : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -48,15 +48,14 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class IndyVCD : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class Key2AudioXS : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -65,7 +65,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class MediaCloQ : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -28,15 +28,14 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -21,15 +21,14 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -8,7 +8,7 @@ namespace BurnOutSharp.ProtectionType
public class ProtectDVDVideo : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> 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<string>() { "Protect DVD-Video" };
}
}

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class SafeCast : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -61,7 +61,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
List<string> protections = new List<string>();
@@ -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;
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class SafeDiscLite : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -51,7 +51,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class SoftLock : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -86,7 +86,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -120,7 +120,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,7 +6,7 @@ namespace BurnOutSharp.ProtectionType
public class Steam : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class TZCopyProtector : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -42,7 +42,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
List<string> protections = new List<string>();
@@ -71,7 +71,7 @@ namespace BurnOutSharp.ProtectionType
if (protections.Count == 0)
return null;
else
return string.Join(", ", protections);
return protections;
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class Uplay : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -36,15 +36,14 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -21,7 +21,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
@@ -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);
}
/// <inheritdoc/>

View File

@@ -6,15 +6,14 @@ namespace BurnOutSharp.ProtectionType
public class Winlock : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
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);
}
/// <inheritdoc/>

View File

@@ -40,7 +40,7 @@ namespace BurnOutSharp.ProtectionType
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> 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<string>() { xcpVersion };
}
return "XCP";
return new List<string>() { "XCP" };
}
return null;

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.ProtectionType
public class Zzxzz : IPathCheck
{
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
public List<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
@@ -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);
}
/// <inheritdoc/>

View File

@@ -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<string> protection = pathCheckClass.CheckDirectoryPath(path, files);
if (protection != null)
protections.AddRange(protection);
}
// Create and return the dictionary