[SimpleSort] This can be multithreaded...

This commit is contained in:
Matt Nadareski
2016-10-17 15:08:49 -07:00
parent d433e81d60
commit b9d8ce356c

View File

@@ -209,27 +209,30 @@ namespace SabreTools.Helper
// Create a list of just files from inputs // Create a list of just files from inputs
List<string> files = new List<string>(); List<string> files = new List<string>();
foreach (string input in _inputs) Parallel.ForEach(_inputs,
{ new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism, },
if (File.Exists(input)) input => {
{ if (File.Exists(input))
_logger.Verbose("File found: '" + input + "'");
files.Add(Path.GetFullPath(input));
}
else if (Directory.Exists(input))
{
_logger.Verbose("Directory found: '" + input + "'");
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{ {
_logger.Verbose("File found: '" + file + "'"); _logger.Verbose("File found: '" + input + "'");
files.Add(Path.GetFullPath(file)); files.Add(Path.GetFullPath(input));
} }
} else if (Directory.Exists(input))
else {
{ _logger.Verbose("Directory found: '" + input + "'");
_logger.Error("'" + input + "' is not a file or directory!"); Parallel.ForEach(Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories),
} new ParallelOptions { MaxDegreeOfParallelism = _maxDegreeOfParallelism, },
} file =>
{
_logger.Verbose("File found: '" + file + "'");
files.Add(Path.GetFullPath(file));
});
}
else
{
_logger.Error("'" + input + "' is not a file or directory!");
}
});
_logger.User("Retrieving complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); _logger.User("Retrieving complete in: " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
// Then, loop through and check each of the inputs // Then, loop through and check each of the inputs