mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, FileTools] Implement custom traversal of directories
This commit is contained in:
@@ -601,8 +601,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (Directory.Exists(input))
|
if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
List<string> files = Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories).ToList();
|
List<string> files = FileTools.RetrieveFiles(input, new List<string>());
|
||||||
files.Sort(new NaturalComparer());
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using OCRC;
|
using OCRC;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
@@ -12,6 +13,31 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
#region File Information
|
#region File Information
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a list of files from a directory recursively in proper order
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directory">Directory to parse</param>
|
||||||
|
/// <param name="infiles">List representing existing files</param>
|
||||||
|
/// <returns>List with all new files</returns>
|
||||||
|
public static List<string> RetrieveFiles(string directory, List<string> infiles)
|
||||||
|
{
|
||||||
|
// Take care of the files in the top directory
|
||||||
|
List<string> toadd = Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
toadd.Sort(new NaturalComparer());
|
||||||
|
infiles.AddRange(toadd);
|
||||||
|
|
||||||
|
// Then recurse through and add from the directories
|
||||||
|
List<string> dirs = Directory.EnumerateDirectories(directory, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
dirs.Sort(new NaturalComparer());
|
||||||
|
foreach (string dir in dirs)
|
||||||
|
{
|
||||||
|
infiles = RetrieveFiles(dir, infiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the new list
|
||||||
|
return infiles;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get what type of DAT the input file is
|
/// Get what type of DAT the input file is
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user