diff --git a/ViewModel.cs b/ViewModel.cs index 062dbb9e..8cf0cab2 100644 --- a/ViewModel.cs +++ b/ViewModel.cs @@ -76,6 +76,11 @@ namespace GARbro.GUI } } + public virtual IEnumerable GetFiles (IEnumerable entries) + { + return entries.Select (e => e.Source); + } + public EntryViewModel Find (string name) { return this.FirstOrDefault (e => e.Name.Equals (name, System.StringComparison.OrdinalIgnoreCase)); @@ -180,15 +185,24 @@ namespace GARbro.GUI UpdateModel (pos.ArchivePath); } - public IEnumerable GetFiles (EntryViewModel entry) + public override IEnumerable GetFiles (IEnumerable entries) { - if (!entry.IsDirectory) - return new Entry[] { entry.Source }; - - string path = GetPath (entry.Name); - return from file in Source - where file.Name.StartsWith (path) - select file; + var list = new List(); + 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 + { + string path = GetPath (entry.Name); + list.AddRange (from file in Source + where file.Name.StartsWith (path) + select file); + } + } + return list; } string GetPath (string dir)