Fixed a crash when trying to load files that do not exist

This commit is contained in:
biwa 2020-09-13 10:45:30 +02:00
parent 92c651bede
commit 3218218dcc

View file

@ -469,6 +469,12 @@ namespace CodeImp.DoomBuilder.Data
MemoryStream s = null; MemoryStream s = null;
string casecorrectfilename = GetCorrectCaseForFile(filename); string casecorrectfilename = GetCorrectCaseForFile(filename);
if(casecorrectfilename == null)
{
General.ErrorLogger.Add(ErrorType.Error, "Unable to load file " + filename + ": file doesn't exist");
return null;
}
try try
{ {
lock(this) lock(this)
@ -521,9 +527,16 @@ namespace CodeImp.DoomBuilder.Data
/// <param name="filepathname">File name get the the correctly cased name from</param> /// <param name="filepathname">File name get the the correctly cased name from</param>
/// <returns></returns> /// <returns></returns>
protected override string GetCorrectCaseForFile(string filepathname) protected override string GetCorrectCaseForFile(string filepathname)
{
try
{ {
return files.GetFileInfo(filepathname).filepathname; return files.GetFileInfo(filepathname).filepathname;
} }
catch(KeyNotFoundException e)
{
return null;
}
}
#endregion #endregion