Class PathPatternProcessor
- Namespace
- CivitaiSharp.Tools.Downloads.Patterns
- Assembly
- CivitaiSharp.Tools.dll
Processes path patterns by replacing tokens with actual values.
public static class PathPatternProcessor
- Inheritance
-
PathPatternProcessor
- Inherited Members
Remarks
This processor handles token replacement and path sanitization to ensure generated file paths are valid across all supported platforms.
Invalid characters in token values are replaced with underscores to ensure file system compatibility. Directory separators in patterns are normalized for the current operating system.
Methods
Process(string, IReadOnlyDictionary<string, string>)
Processes a path pattern by replacing tokens with values from the provided dictionary.
public static string Process(string pattern, IReadOnlyDictionary<string, string> tokenValues)
Parameters
patternstringThe pattern containing tokens to replace.
tokenValuesIReadOnlyDictionary<string, string>Dictionary mapping token names (without braces) to their values.
Returns
- string
The processed path with tokens replaced and invalid characters sanitized.
ValidatePattern(string, FrozenSet<string>)
Validates that a path pattern contains only valid tokens.
public static Result<Unit> ValidatePattern(string pattern, FrozenSet<string> validTokens)
Parameters
patternstringThe pattern to validate.
validTokensFrozenSet<string>The set of valid token names (without braces).