mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 20:02:48 +00:00
Handle multiple entries with the same name but different case
This is done so that entries whose keys have a higher ordinal value (lowercase) will replace entries whose keys have a lower ordinal value. This is based on how I've seen GZDoom handle this sort of situation.
This commit is contained in:
parent
2f48255ddf
commit
71f86980fd
1 changed files with 27 additions and 2 deletions
|
@ -77,7 +77,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
if(skipfolder) continue;
|
||||
|
||||
entries.Add(e.filepathname, e);
|
||||
AddOrReplaceEntry(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
continue;
|
||||
}
|
||||
|
||||
entries.Add(e.filepathname, e);
|
||||
AddOrReplaceEntry(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,31 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
// This checks whether a file is in the entry dictionary, adds it if it
|
||||
// isn't, and replaces the existing entry if the new entry is lowercase
|
||||
private void AddOrReplaceEntry(DirectoryFileEntry e)
|
||||
{
|
||||
// If the entry is already in the dictionary, add the one with
|
||||
// greater ordinal value (prefer lowercase)
|
||||
if(entries.ContainsKey(e.filepathname))
|
||||
{
|
||||
// Get the key for the existing entry. It may have a
|
||||
// different case, since the dictionary is set up to be
|
||||
// case insensitive.
|
||||
string existingEntryPath = entries[e.filepathname].filepathname;
|
||||
if(e.filepathname.CompareTo(existingEntryPath) == -1)
|
||||
{
|
||||
entries.Remove(e.filepathname);
|
||||
entries.Add(e.filepathname, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just add the entry, since it's not in the dictionary yet.
|
||||
entries.Add(e.filepathname, e);
|
||||
}
|
||||
}
|
||||
|
||||
// This checks if a given file exists
|
||||
// The given file path must not be absolute
|
||||
public bool FileExists(string filepathname)
|
||||
|
|
Loading…
Reference in a new issue