using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.File;
///
/// Tests if a filename matches the given vlaue
///
public class FileNameMatches: Node
{
///
public override int Inputs => 1;
///
public override int Outputs => 2;
///
public override FlowElementType Type => FlowElementType.Logic;
///
public override string Icon => "fas fa-equals";
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/file-name-matches";
///
public override bool FailureNode => true;
///
/// Gets or sets the value to match against
///
[TextVariable(1)]
[Required]
public string Value { get; set; }
///
public override int Execute(NodeParameters args)
{
var value = args.ReplaceVariables(Value, stripMissing: true);
var matches = args.StringHelper.Matches(args.LibraryFileName, Value);
if (matches)
{
args.Logger?.ILog("Matches");
return 1;
}
args.Logger?.ILog("Does not match");
return 2;
}
}