mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
Add save detection exception handling
Yay for jksv allowing invalid filenames
This commit is contained in:
parent
247864ce8f
commit
3a377f9198
1 changed files with 12 additions and 2 deletions
|
@ -463,8 +463,18 @@ namespace PKHeX
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(folderPath))
|
if (!Directory.Exists(folderPath))
|
||||||
return null;
|
return null;
|
||||||
return Directory.GetFiles(folderPath, "*", deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)
|
string[] files = new string[0];
|
||||||
.Where(f => SizeValidSAV((int)new FileInfo(f).Length));
|
try
|
||||||
|
{
|
||||||
|
var searchOption = deep ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
|
files = Directory.GetFiles(folderPath, "*", searchOption);
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
Util.Error("Error encountered when detecting saves in the following folder:" + Environment.NewLine + folderPath,
|
||||||
|
"Advise manually scanning to remove bad filenames from the folder." + Environment.NewLine + "Likely caused via Homebrew creating invalid filenames.");
|
||||||
|
}
|
||||||
|
return files.Where(f => SizeValidSAV((int)new FileInfo(f).Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue