mirror of
https://github.com/unclshura/splitter.git
synced 2026-06-21 16:12:01 +00:00
22 lines
676 B
C#
22 lines
676 B
C#
namespace splitter;
|
|
|
|
public static class FileMaskExpander
|
|
{
|
|
public static string[] Expand(string input)
|
|
{
|
|
// If no mask, return the single full path
|
|
if (!HasMask(input))
|
|
return [Path.GetFullPath(input)];
|
|
|
|
string directory = Path.GetDirectoryName(input) ?? Directory.GetCurrentDirectory();
|
|
string pattern = Path.GetFileName(input);
|
|
|
|
if (string.IsNullOrEmpty(directory))
|
|
directory = Directory.GetCurrentDirectory();
|
|
|
|
return Directory.GetFiles(directory, pattern, SearchOption.TopDirectoryOnly);
|
|
}
|
|
|
|
private static bool HasMask(string path)
|
|
=> path.IndexOfAny(['*', '?']) >= 0;
|
|
} |