Skip to content

Commit

Permalink
Merge pull request #33 from LaughingLeader/master
Browse files Browse the repository at this point in the history
Quick regex exception fix, TypeCoercionsWhitelist typo fix
  • Loading branch information
Norbyte authored Jan 3, 2020
2 parents 81d0b0f + 9d4b6c3 commit 11968f1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
46 changes: 29 additions & 17 deletions Divine/CLI/CommandLineActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,35 @@ private static void SetUpAndValidate(CommandLineArguments args)

private static void Process(CommandLineArguments args)
{
var expression = new Regex("^" + Regex.Escape(args.Expression).Replace(@"\*", ".*").Replace(@"\?", ".") + "$", RegexOptions.Singleline | RegexOptions.Compiled);

if (args.UseRegex)
{
try
{
expression = new Regex(args.Expression, RegexOptions.Singleline | RegexOptions.Compiled);
}
catch (ArgumentException)
{
CommandLineLogger.LogFatal($"Cannot parse RegEx expression: {args.Expression}", -1);
}
}

Func<AbstractFileInfo, bool> filter = obj => obj.Name.Like(expression);

switch (args.Action)
Func<AbstractFileInfo, bool> filter;

if (args.Expression != null)
{
Regex expression = null;
if (args.UseRegex)
{
try
{
expression = new Regex(args.Expression, RegexOptions.Singleline | RegexOptions.Compiled);
}
catch (ArgumentException)
{
CommandLineLogger.LogFatal($"Cannot parse RegEx expression: {args.Expression}", -1);
}
}
else
{
expression = new Regex("^" + Regex.Escape(args.Expression).Replace(@"\*", ".*").Replace(@"\?", ".") + "$", RegexOptions.Singleline | RegexOptions.Compiled);
}

filter = obj => obj.Name.Like(expression);
}
else
{
filter = obj => true;
}

switch (args.Action)
{
case "create-package":
{
Expand Down
2 changes: 1 addition & 1 deletion LSLib/LS/Mods/ModResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public void DiscoverModDirectory(string modName, string modPath, string publicPa
}

var typeCoercionWhitelistPath = modPath + @"\Story\RawFiles\TypeCoercionWhitelist.txt";
if (File.Exists(headerPath))
if (File.Exists(typeCoercionWhitelistPath))
{
var fileInfo = new FilesystemFileInfo
{
Expand Down

0 comments on commit 11968f1

Please sign in to comment.