mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 14:58:19 -05:00
Fixed another potential blank error message
I also added comments where appropriate, because it took far too long to understand what was going on when reviewing the commit that fixed the original bug.
This commit is contained in:
@@ -539,7 +539,7 @@ public static SaveFile GetBlankSAV(int generation, string OT)
|
||||
/// </summary>
|
||||
/// <param name="folderPath">Folder to look within</param>
|
||||
/// <param name="deep">Search all subfolders</param>
|
||||
/// <param name="result">Full path of all save files that match criteria.</param>
|
||||
/// <param name="result">If this function returns true, full path of all save files that match criteria. If this function returns false, the error message, or null if the directory could not be found</param>
|
||||
/// <returns>Boolean indicating whether or not operation was successful.</returns>
|
||||
public static bool GetSavesFromFolder(string folderPath, bool deep, out IEnumerable<string> result)
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ private void FormLoadInitialFiles(string[] args)
|
||||
try
|
||||
{
|
||||
if (!DetectSaveFile(out string path) && path != null)
|
||||
WinFormsUtil.Error(path);
|
||||
WinFormsUtil.Error(path); // `path` contains the error message
|
||||
|
||||
if (path != null && File.Exists(path))
|
||||
OpenQuick(path, force: true);
|
||||
|
||||
@@ -44,7 +44,9 @@ public static string[] Get3DSBackupPaths(string root)
|
||||
/// <summary>
|
||||
/// Detects a save file.
|
||||
/// </summary>
|
||||
/// <returns>Full path of a save file. Returns null if unable to find any.</returns>
|
||||
/// <param name="path">If this function returns true, full path of a save file or null if no path could be found. If this function returns false, this parameter will be set to the error message.</param>
|
||||
/// <param name="extra">Paths to check in addition to the default paths</param>
|
||||
/// <returns>A boolean indicating whether or not a file was detected</returns>
|
||||
public static bool DetectSaveFile(out string path, params string[] extra)
|
||||
{
|
||||
string path3DS = Path.GetPathRoot(Get3DSLocation());
|
||||
@@ -59,10 +61,11 @@ public static bool DetectSaveFile(out string path, params string[] extra)
|
||||
{
|
||||
if (!SaveUtil.GetSavesFromFolder(p, true, out IEnumerable<string> files))
|
||||
{
|
||||
if (files == null)
|
||||
continue;
|
||||
path = files.First(); // error
|
||||
return false;
|
||||
if (files != null) // Could be null if `p` doesn't exist
|
||||
{
|
||||
path = string.Concat(Environment.NewLine, files); // `files` contains the error message
|
||||
return false;
|
||||
}
|
||||
}
|
||||
possiblePaths.AddRange(files);
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ public static bool OpenSAVPKMDialog(string[] Extensions, out string path)
|
||||
string pathCache = CyberGadgetUtil.GetCacheFolder();
|
||||
if (Directory.Exists(pathCache))
|
||||
cgse = Path.Combine(pathCache);
|
||||
if (!PathUtilWindows.DetectSaveFile(out path, cgse))
|
||||
Error(path);
|
||||
if (!PathUtilWindows.DetectSaveFile(out path, cgse) && !string.IsNullOrEmpty(path))
|
||||
Error(path); // `path` contains the error message
|
||||
|
||||
if (path != null)
|
||||
{ ofd.FileName = path; }
|
||||
|
||||
Reference in New Issue
Block a user