Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CASCConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ static void Main(string[] args)

if (mode == "pattern")
{
Wildcard wildcard = new Wildcard(pattern, true, RegexOptions.IgnoreCase);

foreach (var file in CASCFolder.GetFiles(root.Entries.Select(kv => kv.Value)))
foreach (var file in CASCFolder.GetFiles(root.Entries.Select(kv => kv.Value), filter: pattern))
{
if (wildcard.IsMatch(file.FullName))
ExtractFile(cascHandler, file.FullName, dest);
ExtractFile(cascHandler, file.FullName, dest);
}
}
else if (mode == "listfile")
Expand Down
4 changes: 2 additions & 2 deletions CASCExplorer/CASCViewHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CASCViewHelper
public bool AnalyzeSoundFiles { get; set; } = true;
public bool AddFileDataIdToSoundFiles { get; set; } = true;

public void ExtractFiles(NoFlickerListView filesList)
public void ExtractFiles(NoFlickerListView filesList, string filter)
{
if (_currentFolder == null)
return;
Expand All @@ -56,7 +56,7 @@ public void ExtractFiles(NoFlickerListView filesList)
if (extractProgress == null)
extractProgress = new ExtractProgress();

var files = CASCFolder.GetFiles(_displayedEntries, filesList.SelectedIndices.Cast<int>()).ToList();
var files = CASCFolder.GetFiles(_displayedEntries, filesList.SelectedIndices.Cast<int>(), true, filter).ToList();
extractProgress.SetExtractData(_casc, files);
extractProgress.ShowDialog();
}
Expand Down
2 changes: 1 addition & 1 deletion CASCExplorer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private bool NavigateFolder()

private void extractToolStripMenuItem_Click(object sender, EventArgs e)
{
viewHelper.ExtractFiles(fileList);
viewHelper.ExtractFiles(fileList, filterToolStripTextBox.Text);
}

private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
Expand Down
12 changes: 10 additions & 2 deletions CascLib/CASCEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace CASCLib
{
Expand Down Expand Up @@ -34,14 +35,19 @@ public ICASCEntry GetEntry(string name)
return entry;
}

public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IEnumerable<int> selection = null, bool recursive = true)
public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IEnumerable<int> selection = null, bool recursive = true, string filter = "")
{
var wildcard = filter != string.Empty && filter != "*" ? new Wildcard(filter, false, RegexOptions.IgnoreCase) : null;

var entries2 = selection != null ? selection.Select(index => entries.ElementAt(index)) : entries;

foreach (var entry in entries2)
{
if (entry is CASCFile file1)
{
if (wildcard != null && !wildcard.IsMatch(file1.Name))
continue;

yield return file1;
}
else
Expand All @@ -50,8 +56,10 @@ public static IEnumerable<CASCFile> GetFiles(IEnumerable<ICASCEntry> entries, IE
{
var folder = entry as CASCFolder;

foreach (var file in GetFiles(folder.Entries.Select(kv => kv.Value)))
foreach (var file in GetFiles(folder.Entries.Select(kv => kv.Value), filter: filter))
{
if (wildcard != null && !wildcard.IsMatch(file.Name))
continue;
yield return file;
}
}
Expand Down