|
|
|
@ -9,7 +9,7 @@ namespace Restock
|
|
|
|
|
[KSPAddon(KSPAddon.Startup.Instantly, true)]
|
|
|
|
|
public class ResourceBlacklist : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private readonly string[] commentSep = { "//" };
|
|
|
|
|
private readonly string[] COMMENT_SEPARATOR = { "//" };
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
HashSet<UrlDir.UrlFile> blacklist = new HashSet<UrlDir.UrlFile>();
|
|
|
|
@ -24,7 +24,7 @@ namespace Restock
|
|
|
|
|
Debug.Log($"[Restock] Reading blacklist {file.url}.{file.fileExtension}");
|
|
|
|
|
foreach (string line in File.ReadAllLines(file.fullPath))
|
|
|
|
|
{
|
|
|
|
|
string lineBeforeComment = line.Split(commentSep, 2, StringSplitOptions.None)[0].Trim();
|
|
|
|
|
string lineBeforeComment = line.Split(COMMENT_SEPARATOR, 2, StringSplitOptions.None)[0].Trim();
|
|
|
|
|
if (lineBeforeComment == string.Empty) continue;
|
|
|
|
|
|
|
|
|
|
foreach (UrlDir.UrlFile blacklistFile in FindFiles(lineBeforeComment, gameData))
|
|
|
|
@ -38,7 +38,7 @@ namespace Restock
|
|
|
|
|
Debug.Log($"[Restock] Reading whitelist {file.url}.{file.fileExtension}");
|
|
|
|
|
foreach (string line in File.ReadAllLines(file.fullPath))
|
|
|
|
|
{
|
|
|
|
|
string lineBeforeComment = line.Split(commentSep, 2, StringSplitOptions.None)[0].Trim();
|
|
|
|
|
string lineBeforeComment = line.Split(COMMENT_SEPARATOR, 2, StringSplitOptions.None)[0].Trim();
|
|
|
|
|
if (lineBeforeComment == string.Empty) continue;
|
|
|
|
|
|
|
|
|
|
foreach (UrlDir.UrlFile whitelistFile in FindFiles(lineBeforeComment, gameData))
|
|
|
|
@ -62,10 +62,10 @@ namespace Restock
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly char[] sep = new[] { '/' };
|
|
|
|
|
private readonly char[] PATH_SEPARATOR = new[] { '/' };
|
|
|
|
|
private IEnumerable<UrlDir.UrlFile> FindFiles(string url, UrlDir dir)
|
|
|
|
|
{
|
|
|
|
|
string[] splits = url.Split(sep, 2);
|
|
|
|
|
string[] splits = url.Split(PATH_SEPARATOR, 2);
|
|
|
|
|
|
|
|
|
|
if (splits.Length == 1)
|
|
|
|
|
{
|
|
|
|
|