public void Search_Walk(bool include_dir = false, string regex = null)
{
string path = Action.path;
List<string> list_paths = new List<string>();
// check glob path
{
string rev_slash = path.Replace('\\', '/');
if (Glob.HasGlobPattern(rev_slash))
{
IEnumerable<string> paths = Glob.GetMatches(rev_slash, Glob.Constants.IgnoreCase);
// since we have glob in our path
// let's take that off
list_paths.Clear();
// add insert a new ones
list_paths.AddRange(paths);
}
else
{
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists) { list_paths.Add(path); }
}
}
foreach (string currPath in list_paths)
{
// confirm if such directory exists
DirectoryInfo di = new DirectoryInfo(currPath.Replace('/', '\\'));
if (di.Exists)
{
// get the following files.
List<string> files = FileOperations.I.GetFilesRecursive(currPath, regex, (s) =>
{
ProgressWorker.I.EnQ("Scanning directory " + s);
});
files.Reverse();
foreach (string file in files)
{
if (!IsWhitelisted(file))
{
// enqueue file for deletion
Worker.I.EnqueTTD(new Model_ThingsToDelete()
{
FullPathName = file,
IsWhitelisted = false,
OverWrite = false,
WhatKind = THINGS_TO_DELETE.file,
command = COMMANDS.delete,
search = include_dir ? SEARCH.walk_all : SEARCH.walk_files,
path = di.FullName,
level = Action.parent_option.level,
cleaner_name = Action.parent_option.label
});
}
}
}
}
}