mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify some Folder logic
This commit is contained in:
@@ -225,30 +225,24 @@ namespace SabreTools.FileTypes
|
||||
if (Filename == null)
|
||||
return null;
|
||||
|
||||
if (_children == null || _children.Count == 0)
|
||||
{
|
||||
// If we already have children
|
||||
if (_children != null && _children.Count > 0)
|
||||
return _children;
|
||||
|
||||
// Build the child item list
|
||||
_children = [];
|
||||
#if NET20 || NET35
|
||||
foreach (string file in Directory.GetFiles(Filename, "*"))
|
||||
#else
|
||||
foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||
#endif
|
||||
foreach (string file in IOExtensions.SafeEnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
BaseFile? nf = FileTypeTool.GetInfo(file, _hashTypes);
|
||||
if (nf != null)
|
||||
_children.Add(nf);
|
||||
}
|
||||
|
||||
#if NET20 || NET35
|
||||
foreach (string dir in Directory.GetDirectories(Filename, "*"))
|
||||
#else
|
||||
foreach (string dir in Directory.EnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||
#endif
|
||||
foreach (string dir in IOExtensions.SafeEnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
var fl = new Folder(dir);
|
||||
_children.Add(fl);
|
||||
}
|
||||
}
|
||||
|
||||
return _children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user