mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Merge pull request #310 from blowfishpro/AllowEmptyLinesAndCommentsInBlacklist
Allow empty lines and comments in blacklist/whitelist
This commit is contained in:
commit
beaee80138
Binary file not shown.
@ -9,6 +9,7 @@ namespace Restock
|
|||||||
[KSPAddon(KSPAddon.Startup.Instantly, true)]
|
[KSPAddon(KSPAddon.Startup.Instantly, true)]
|
||||||
public class ResourceBlacklist : MonoBehaviour
|
public class ResourceBlacklist : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private readonly string[] commentSep = { "//" };
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
HashSet<UrlDir.UrlFile> blacklist = new HashSet<UrlDir.UrlFile>();
|
HashSet<UrlDir.UrlFile> blacklist = new HashSet<UrlDir.UrlFile>();
|
||||||
@ -23,7 +24,10 @@ namespace Restock
|
|||||||
Debug.Log($"[Restock] Reading blacklist {file.url}.{file.fileExtension}");
|
Debug.Log($"[Restock] Reading blacklist {file.url}.{file.fileExtension}");
|
||||||
foreach (string line in File.ReadAllLines(file.fullPath))
|
foreach (string line in File.ReadAllLines(file.fullPath))
|
||||||
{
|
{
|
||||||
foreach (UrlDir.UrlFile blacklistFile in FindFiles(line, gameData))
|
string lineBeforeComment = line.Split(commentSep, 2, StringSplitOptions.None)[0].Trim();
|
||||||
|
if (lineBeforeComment == string.Empty) continue;
|
||||||
|
|
||||||
|
foreach (UrlDir.UrlFile blacklistFile in FindFiles(lineBeforeComment, gameData))
|
||||||
{
|
{
|
||||||
blacklist.Add(blacklistFile);
|
blacklist.Add(blacklistFile);
|
||||||
}
|
}
|
||||||
@ -34,7 +38,10 @@ namespace Restock
|
|||||||
Debug.Log($"[Restock] Reading whitelist {file.url}.{file.fileExtension}");
|
Debug.Log($"[Restock] Reading whitelist {file.url}.{file.fileExtension}");
|
||||||
foreach (string line in File.ReadAllLines(file.fullPath))
|
foreach (string line in File.ReadAllLines(file.fullPath))
|
||||||
{
|
{
|
||||||
foreach (UrlDir.UrlFile whitelistFile in FindFiles(line, gameData))
|
string lineBeforeComment = line.Split(commentSep, 2, StringSplitOptions.None)[0].Trim();
|
||||||
|
if (lineBeforeComment == string.Empty) continue;
|
||||||
|
|
||||||
|
foreach (UrlDir.UrlFile whitelistFile in FindFiles(lineBeforeComment, gameData))
|
||||||
{
|
{
|
||||||
whitelist.Add(whitelistFile);
|
whitelist.Add(whitelistFile);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user