mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(DirectoryViewModel.GetFiles): new virtual method.
This commit is contained in:
parent
8e0f1a36ff
commit
23030ac225
26
ViewModel.cs
26
ViewModel.cs
@ -76,6 +76,11 @@ namespace GARbro.GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<Entry> GetFiles (IEnumerable<EntryViewModel> entries)
|
||||||
|
{
|
||||||
|
return entries.Select (e => e.Source);
|
||||||
|
}
|
||||||
|
|
||||||
public EntryViewModel Find (string name)
|
public EntryViewModel Find (string name)
|
||||||
{
|
{
|
||||||
return this.FirstOrDefault (e => e.Name.Equals (name, System.StringComparison.OrdinalIgnoreCase));
|
return this.FirstOrDefault (e => e.Name.Equals (name, System.StringComparison.OrdinalIgnoreCase));
|
||||||
@ -180,15 +185,24 @@ namespace GARbro.GUI
|
|||||||
UpdateModel (pos.ArchivePath);
|
UpdateModel (pos.ArchivePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Entry> GetFiles (EntryViewModel entry)
|
public override IEnumerable<Entry> GetFiles (IEnumerable<EntryViewModel> entries)
|
||||||
|
{
|
||||||
|
var list = new List<Entry>();
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
if (!entry.IsDirectory) // add ordinary file
|
||||||
|
list.Add (entry.Source);
|
||||||
|
else if (".." == entry.Name) // skip reference to parent directory
|
||||||
|
continue;
|
||||||
|
else // add all files contained within directory, recursive
|
||||||
{
|
{
|
||||||
if (!entry.IsDirectory)
|
|
||||||
return new Entry[] { entry.Source };
|
|
||||||
|
|
||||||
string path = GetPath (entry.Name);
|
string path = GetPath (entry.Name);
|
||||||
return from file in Source
|
list.AddRange (from file in Source
|
||||||
where file.Name.StartsWith (path)
|
where file.Name.StartsWith (path)
|
||||||
select file;
|
select file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetPath (string dir)
|
string GetPath (string dir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user