2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
using System.IO;
|
2022-05-01 17:41:50 -07:00
|
|
|
|
using BurnOutSharp.Interfaces;
|
2021-03-22 22:07:14 -07:00
|
|
|
|
using BurnOutSharp.Matching;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
|
{
|
2021-02-26 00:32:09 -08:00
|
|
|
|
public class AACS : IPathCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-02-26 00:32:09 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
|
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-22 22:07:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-22 22:12:25 -07:00
|
|
|
|
// BD-ROM
|
2021-07-17 22:31:29 -07:00
|
|
|
|
new PathMatchSet(Path.Combine("AACS", "MKB_RO.inf").Replace("\\", "/"), GetVersion, "AACS"),
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
2021-03-22 22:07:14 -07:00
|
|
|
|
// HD-DVD
|
2021-07-17 22:31:29 -07:00
|
|
|
|
new PathMatchSet(Path.Combine("AACS", "MKBROM.AACS").Replace("\\", "/"), GetVersion, "AACS"),
|
2021-03-22 22:07:14 -07:00
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 13:35:12 -07:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-22 22:07:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2021-03-19 15:41:49 -07:00
|
|
|
|
{
|
2021-03-22 22:12:25 -07:00
|
|
|
|
// BD-ROM
|
2021-03-22 22:23:55 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("MKB_RO.inf", useEndsWith: true), GetVersion, "AACS"),
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
2021-03-22 22:07:14 -07:00
|
|
|
|
// HD-DVD
|
2021-03-22 22:23:55 -07:00
|
|
|
|
new PathMatchSet(new PathMatch("MKBROM.AACS", useEndsWith: true), GetVersion, "AACS"),
|
2021-03-22 22:07:14 -07:00
|
|
|
|
};
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
2021-03-22 22:09:35 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-22 22:11:01 -07:00
|
|
|
|
public static string GetVersion(string firstMatchedString, IEnumerable<string> files)
|
2021-03-17 23:27:37 -06:00
|
|
|
|
{
|
2021-03-22 22:11:01 -07:00
|
|
|
|
if (!File.Exists(firstMatchedString))
|
2021-03-22 22:07:14 -07:00
|
|
|
|
return "(Unknown Version)";
|
2021-03-21 14:30:37 -07:00
|
|
|
|
|
2021-03-17 23:27:37 -06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-03-22 22:11:01 -07:00
|
|
|
|
using (var fs = File.OpenRead(firstMatchedString))
|
2021-03-17 23:27:37 -06:00
|
|
|
|
{
|
|
|
|
|
|
fs.Seek(0xB, SeekOrigin.Begin);
|
2021-03-22 22:07:14 -07:00
|
|
|
|
return fs.ReadByte().ToString();
|
2021-03-17 23:27:37 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
2021-03-22 22:07:14 -07:00
|
|
|
|
return "(Unknown Version)";
|
2021-03-17 23:27:37 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|