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,29 +225,23 @@ namespace SabreTools.FileTypes
|
|||||||
if (Filename == null)
|
if (Filename == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_children == null || _children.Count == 0)
|
// If we already have children
|
||||||
{
|
if (_children != null && _children.Count > 0)
|
||||||
_children = [];
|
return _children;
|
||||||
#if NET20 || NET35
|
|
||||||
foreach (string file in Directory.GetFiles(Filename, "*"))
|
|
||||||
#else
|
|
||||||
foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
BaseFile? nf = FileTypeTool.GetInfo(file, _hashTypes);
|
|
||||||
if (nf != null)
|
|
||||||
_children.Add(nf);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if NET20 || NET35
|
// Build the child item list
|
||||||
foreach (string dir in Directory.GetDirectories(Filename, "*"))
|
_children = [];
|
||||||
#else
|
foreach (string file in IOExtensions.SafeEnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
foreach (string dir in Directory.EnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly))
|
{
|
||||||
#endif
|
BaseFile? nf = FileTypeTool.GetInfo(file, _hashTypes);
|
||||||
{
|
if (nf != null)
|
||||||
var fl = new Folder(dir);
|
_children.Add(nf);
|
||||||
_children.Add(fl);
|
}
|
||||||
}
|
|
||||||
|
foreach (string dir in IOExtensions.SafeEnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
|
{
|
||||||
|
var fl = new Folder(dir);
|
||||||
|
_children.Add(fl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _children;
|
return _children;
|
||||||
|
|||||||
Reference in New Issue
Block a user