diff --git a/JL.Core/Dicts/EPWING/Yomichan/EpwingYomichanLoader.cs b/JL.Core/Dicts/EPWING/Yomichan/EpwingYomichanLoader.cs index e50e1e26..07dcd54f 100644 --- a/JL.Core/Dicts/EPWING/Yomichan/EpwingYomichanLoader.cs +++ b/JL.Core/Dicts/EPWING/Yomichan/EpwingYomichanLoader.cs @@ -14,7 +14,9 @@ public static async Task Load(Dict dict) return; } - IEnumerable jsonFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly); + IEnumerable jsonFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Where(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + foreach (string jsonFile in jsonFiles) { List>? jsonElementLists; diff --git a/JL.Core/Freqs/FrequencyYomichan/FrequencyYomichanLoader.cs b/JL.Core/Freqs/FrequencyYomichan/FrequencyYomichanLoader.cs index 92d63c21..f56129d2 100644 --- a/JL.Core/Freqs/FrequencyYomichan/FrequencyYomichanLoader.cs +++ b/JL.Core/Freqs/FrequencyYomichan/FrequencyYomichanLoader.cs @@ -15,7 +15,9 @@ public static async Task Load(Freq freq) return; } - IEnumerable jsonFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly); + IEnumerable jsonFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Where(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + foreach (string jsonFile in jsonFiles) { List>? frequencyJson; diff --git a/JL.Windows/GUI/AddDictionaryWindow.xaml.cs b/JL.Windows/GUI/AddDictionaryWindow.xaml.cs index 046d858e..07d873df 100644 --- a/JL.Windows/GUI/AddDictionaryWindow.xaml.cs +++ b/JL.Windows/GUI/AddDictionaryWindow.xaml.cs @@ -79,7 +79,9 @@ private void SaveButton_Click(object sender, RoutedEventArgs e) } else { - bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly).Any(); + bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Any(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + if (!validPath) { TextBlockPath.BorderBrush = Brushes.Red; diff --git a/JL.Windows/GUI/AddFrequencyWindow.xaml.cs b/JL.Windows/GUI/AddFrequencyWindow.xaml.cs index 06a45ef3..33e409e9 100644 --- a/JL.Windows/GUI/AddFrequencyWindow.xaml.cs +++ b/JL.Windows/GUI/AddFrequencyWindow.xaml.cs @@ -65,7 +65,9 @@ private void SaveButton_Click(object sender, RoutedEventArgs e) FreqType type = typeString!.GetEnum(); if (type is FreqType.Yomichan or FreqType.YomichanKanji) { - bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly).Any(); + bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Any(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + if (!validPath) { TextBlockPath.BorderBrush = Brushes.Red; diff --git a/JL.Windows/GUI/EditDictionaryWindow.xaml.cs b/JL.Windows/GUI/EditDictionaryWindow.xaml.cs index ba38d986..2f1d47aa 100644 --- a/JL.Windows/GUI/EditDictionaryWindow.xaml.cs +++ b/JL.Windows/GUI/EditDictionaryWindow.xaml.cs @@ -79,7 +79,9 @@ private void SaveButton_Click(object sender, RoutedEventArgs e) } else { - bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly).Any(); + bool validPath = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Any(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + if (!validPath) { TextBlockPath.BorderBrush = Brushes.Red; diff --git a/JL.Windows/GUI/EditFrequencyWindow.xaml.cs b/JL.Windows/GUI/EditFrequencyWindow.xaml.cs index 5a7459b8..7d984ac0 100644 --- a/JL.Windows/GUI/EditFrequencyWindow.xaml.cs +++ b/JL.Windows/GUI/EditFrequencyWindow.xaml.cs @@ -66,7 +66,9 @@ private void SaveButton_Click(object sender, RoutedEventArgs e) { if (_freq.Type is FreqType.Yomichan or FreqType.YomichanKanji) { - bool hasValidFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly).Any(); + bool hasValidFiles = Directory.EnumerateFiles(fullPath, "*_bank_*.json", SearchOption.TopDirectoryOnly) + .Any(static s => s.StartsWith("term", StringComparison.Ordinal) || s.StartsWith("kanji", StringComparison.Ordinal)); + if (!hasValidFiles) { TextBlockPath.BorderBrush = Brushes.Red;