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()));
|
Console.WriteLine(Helpers.Converters.GetSpecialToAbsolutePath(Console.ReadLine().ToUpper()));
|
||||||
break;
|
break;
|
||||||
case "B":
|
case "B":
|
||||||
//var dir = Helpers.Filters.GetFileList(@"D:\Temp");
|
|
||||||
string fullPath = Path.Combine(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") , @"BioWare\Mass Effect Andromeda");
|
string fullPath = Path.Combine(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") , @"BioWare\Mass Effect Andromeda");
|
||||||
string relPath = fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", string.Empty);
|
string relPath = fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", string.Empty);
|
||||||
|
|
||||||
Console.WriteLine($"Full: {fullPath}");
|
Console.WriteLine($"Full: {fullPath}");
|
||||||
Console.WriteLine($"Relative Path: {relPath}");
|
Console.WriteLine($"Relative Path: {relPath}");
|
||||||
|
|
||||||
PrintListValues(Helpers.Filters.FilterDirectory(fullPath, @"*.*", ""));
|
PrintListValues(Helpers.Filters.FilterDirectory(fullPath, @"*ManualSave|*AutoSave", @"BioWare\Mass Effect Andromeda\Save\*"));
|
||||||
FSManipulation.CopyDirectory(
|
|
||||||
fullPath,
|
//FSManipulation.CopyDirectory(
|
||||||
fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", @"D:\Temp\TEST\"));
|
// fullPath,
|
||||||
|
// fullPath.Replace(Helpers.Converters.GetSpecialToAbsolutePath("%DOCUMENTS%") + "\\", @"D:\Temp\TEST\"));
|
||||||
break;
|
break;
|
||||||
case "X":
|
case "X":
|
||||||
break;
|
break;
|
||||||
|
|||||||
+49
-13
@@ -69,21 +69,17 @@ namespace FirelanceMgr
|
|||||||
|
|
||||||
public static List<string> FilterDirectory(string fullPath, string inclusionStr, string exclusionStr)
|
public static List<string> FilterDirectory(string fullPath, string inclusionStr, string exclusionStr)
|
||||||
{
|
{
|
||||||
var filteredList = new List<string>();
|
var incBuilder = PatternBuilder(inclusionStr);
|
||||||
var inclusionList = Builder(fullPath, inclusionStr);
|
var excBuilder = PatternBuilder(exclusionStr);
|
||||||
var exclusionList = Builder(fullPath, exclusionStr);
|
var inclusionList = ManifestBuilder(incBuilder, fullPath);
|
||||||
|
var exclusionList = ManifestBuilder(excBuilder, fullPath);
|
||||||
|
|
||||||
foreach (var item in inclusionList)
|
|
||||||
{
|
return inclusionList;
|
||||||
if (exclusionList.Contains(item) == false) { filteredList.Add(item); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredList;
|
private static List<string> PatternBuilder(string filterStr)
|
||||||
}
|
|
||||||
|
|
||||||
private static List<string> Builder(string fullPath, string filterStr)
|
|
||||||
{
|
{
|
||||||
var filteredList = new List<string>();
|
|
||||||
var filters = new List<string>();
|
var filters = new List<string>();
|
||||||
|
|
||||||
if (filterStr != string.Empty)
|
if (filterStr != string.Empty)
|
||||||
@@ -100,13 +96,53 @@ namespace FirelanceMgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
filters.Add(currentFilter); // Add final inclusion
|
filters.Add(currentFilter); // Add final inclusion
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in filters)
|
return filters;
|
||||||
foreach (var file in Directory.GetFiles(fullPath, item, SearchOption.AllDirectories))
|
}
|
||||||
|
|
||||||
|
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);
|
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;
|
return filteredList;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user