Firelance 0.1.5.1
- Rewrote ManifestBuilder as directory filters are not fully supported causing exceptions with many patterns - FilterDirectory needs completing
This commit is contained in:
@@ -208,17 +208,17 @@ namespace DevConsole
|
||||
Console.WriteLine(Helpers.Converters.GetSpecialToAbsolutePath(Console.ReadLine().ToUpper()));
|
||||
break;
|
||||
case "B":
|
||||
//var dir = Helpers.Filters.GetFileList(@"D:\Temp");
|
||||
string fullPath = Path.Combine(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") , @"BioWare\Mass Effect Andromeda");
|
||||
string relPath = fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", string.Empty);
|
||||
|
||||
Console.WriteLine($"Full: {fullPath}");
|
||||
Console.WriteLine($"Relative Path: {relPath}");
|
||||
|
||||
PrintListValues(Helpers.Filters.FilterDirectory(fullPath, @"*.*", ""));
|
||||
FSManipulation.CopyDirectory(
|
||||
fullPath,
|
||||
fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", @"D:\Temp\TEST\"));
|
||||
PrintListValues(Helpers.Filters.FilterDirectory(fullPath, @"*ManualSave|*AutoSave", @"BioWare\Mass Effect Andromeda\Save\*"));
|
||||
|
||||
//FSManipulation.CopyDirectory(
|
||||
// fullPath,
|
||||
// fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", @"D:\Temp\TEST\"));
|
||||
break;
|
||||
case "X":
|
||||
break;
|
||||
|
||||
+48
-12
@@ -69,21 +69,17 @@ namespace FirelanceMgr
|
||||
|
||||
public static List<string> FilterDirectory(string fullPath, string inclusionStr, string exclusionStr)
|
||||
{
|
||||
var filteredList = new List<string>();
|
||||
var inclusionList = Builder(fullPath, inclusionStr);
|
||||
var exclusionList = Builder(fullPath, exclusionStr);
|
||||
var incBuilder = PatternBuilder(inclusionStr);
|
||||
var excBuilder = PatternBuilder(exclusionStr);
|
||||
var inclusionList = ManifestBuilder(incBuilder, fullPath);
|
||||
var exclusionList = ManifestBuilder(excBuilder, fullPath);
|
||||
|
||||
foreach (var item in inclusionList)
|
||||
{
|
||||
if (exclusionList.Contains(item) == false) { filteredList.Add(item); }
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
return inclusionList;
|
||||
}
|
||||
|
||||
private static List<string> Builder(string fullPath, string filterStr)
|
||||
private static List<string> PatternBuilder(string filterStr)
|
||||
{
|
||||
var filteredList = new List<string>();
|
||||
var filters = new List<string>();
|
||||
|
||||
if (filterStr != string.Empty)
|
||||
@@ -100,12 +96,52 @@ namespace FirelanceMgr
|
||||
}
|
||||
}
|
||||
filters.Add(currentFilter); // Add final inclusion
|
||||
}
|
||||
|
||||
foreach (var item in filters)
|
||||
foreach (var file in Directory.GetFiles(fullPath, item, SearchOption.AllDirectories))
|
||||
return filters;
|
||||
}
|
||||
|
||||
private static List<string> ManifestBuilder(List<string> filters, string fullPath)
|
||||
{
|
||||
var filteredList = new List<string>();
|
||||
|
||||
foreach (var f in filters)
|
||||
{
|
||||
if (f == "*.*")
|
||||
{
|
||||
// Pattern: All
|
||||
foreach (var file in Directory.GetFiles(fullPath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
filteredList.Add(file);
|
||||
}
|
||||
}
|
||||
else if (f.Contains(@"\*"))
|
||||
{
|
||||
// Pattern: Directory
|
||||
foreach (var dir in Directory.GetDirectories(fullPath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
if (dir.Contains(f.Substring(0, f.LastIndexOf("\\")))) { filteredList.Add(dir); }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (f.Contains("*"))
|
||||
{
|
||||
// Pattern: File with wildcard
|
||||
foreach (var file in Directory.GetFiles(fullPath, f, SearchOption.AllDirectories))
|
||||
{
|
||||
filteredList.Add(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pattern: File
|
||||
if (File.Exists(f))
|
||||
{
|
||||
filteredList.Add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filteredList;
|
||||
|
||||
Reference in New Issue
Block a user