(FileExists): check filename without directory first.

This commit is contained in:
morkt 2023-09-07 12:30:14 +04:00
parent 97aed46293
commit a7d9b9c8dd

View File

@ -263,7 +263,9 @@ namespace GameRes
public bool FileExists (string filename)
{
return m_dir.ContainsKey (CombinePath (CurrentDirectory, filename));
return m_dir.ContainsKey (filename)
|| !string.IsNullOrEmpty (CurrentDirectory)
&& m_dir.ContainsKey (CombinePath (CurrentDirectory, filename));
}
public Stream OpenStream (Entry entry)
@ -408,6 +410,8 @@ namespace GameRes
Entry entry = null;
if (m_dir.TryGetValue (filename, out entry))
return entry;
if (m_dir.TryGetValue (CombinePath (CurrentDirectory, filename), out entry))
return entry;
var dir_name = filename + PathDelimiter;
if (m_dir.Keys.Any (n => n.StartsWith (dir_name)))
return new SubDirEntry (filename);