Added Prism to example, Added ability to filter files and minor bugfixes

This commit is contained in:
Holger Boerchers
2018-07-28 23:57:14 +02:00
parent a18f7b0837
commit 0ed81d68c8
38 changed files with 15713 additions and 44 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Minimatch;
using Vestris.ResourceLib;
namespace KattekerCreator.Helper
@ -73,25 +74,33 @@ namespace KattekerCreator.Helper
#endif
}
public static IEnumerable<FileInfo> EnumerateFiles(string programFile, IEnumerable<string> userdefinedFileExclusions = null)
public static IList<FileInfo> EnumerateFiles(string path, IEnumerable<string> userdefinedFileExclusions = null)
{
if (string.IsNullOrWhiteSpace(programFile)) return null;
var directoryName = Path.GetDirectoryName(programFile);
if (directoryName == null) return null;
var files = new DirectoryInfo(directoryName).EnumerateFiles("*.*", SearchOption.AllDirectories);
var filter = FileExclusions(userdefinedFileExclusions).ToArray();
return files.Where(x => !filter.Any(y => x.Name.EndsWith(y, StringComparison.Ordinal)));
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullException(nameof(path));
var result = new DirectoryInfo(path).EnumerateFiles("*.*", SearchOption.AllDirectories).ToList();
var minimatchOptions = new Options {AllowWindowsPaths = true};
foreach (var pattern in FileExclusions(userdefinedFileExclusions))
{
var matcher = new Minimatcher(pattern, minimatchOptions);
for (var index = result.Count - 1; index >= 0; index--)
{
if (matcher.IsMatch(result[index].Name))
{
result.Remove(result[index]);
}
}
}
return result;
}
private static IEnumerable<string> FileExclusions(IEnumerable<string> userdefinedfileExclusions = null)
{
yield return ".pdb";
yield return ".tmp";
yield return ".obj";
yield return ".pch";
yield return ".vshost.exe";
yield return ".vshost.exe.config";
yield return ".vshost.exe.manifest";
yield return "*.pdb";
yield return "*.tmp";
yield return "*.obj";
yield return "*.pch";
yield return "*.vshost.exe*";
yield return "squirrelHelperInfo.json";
yield return "Katteker.config";