(FileSystem): use case-insensitive comparison.

This commit is contained in:
morkt 2018-01-20 13:24:26 +04:00
parent 7d7f5a71d2
commit 7031f56eb0

View File

@ -386,7 +386,7 @@ namespace GameRes
if (!string.IsNullOrEmpty (root_dir)) if (!string.IsNullOrEmpty (root_dir))
root_dir += PathDelimiter; root_dir += PathDelimiter;
var subdirs = new HashSet<string>(); var subdirs = new HashSet<string> (StringComparer.InvariantCultureIgnoreCase);
foreach (var entry in dir) foreach (var entry in dir)
{ {
var match = path_re.Match (entry.Name, root_dir.Length); var match = path_re.Match (entry.Name, root_dir.Length);
@ -412,7 +412,7 @@ namespace GameRes
return m_arc.Dir; return m_arc.Dir;
var path = m_cwd + PathDelimiter; var path = m_cwd + PathDelimiter;
return from file in m_arc.Dir return from file in m_arc.Dir
where file.Name.StartsWith (path) where file.Name.StartsWith (path, StringComparison.InvariantCultureIgnoreCase)
select file; select file;
} }
@ -430,7 +430,8 @@ namespace GameRes
else else
{ {
path += PathDelimiter; path += PathDelimiter;
return m_arc.Dir.Where (f => f.Name.StartsWith (path) && glob.IsMatch (Path.GetFileName (f.Name))); return m_arc.Dir.Where (f => f.Name.StartsWith (path, StringComparison.InvariantCultureIgnoreCase)
&& glob.IsMatch (Path.GetFileName (f.Name)));
} }
} }
@ -447,7 +448,7 @@ namespace GameRes
{ {
var dir_name = entry.Name+PathDelimiter; var dir_name = entry.Name+PathDelimiter;
result.AddRange (from file in m_arc.Dir result.AddRange (from file in m_arc.Dir
where file.Name.StartsWith (dir_name) where file.Name.StartsWith (dir_name, StringComparison.InvariantCultureIgnoreCase)
select file); select file);
} }
} }
@ -492,7 +493,7 @@ namespace GameRes
if (0 != new_path.Length) if (0 != new_path.Length)
{ {
var dir_name = new_path + PathDelimiter; var dir_name = new_path + PathDelimiter;
var entry = m_arc.Dir.FirstOrDefault (e => e.Name.StartsWith (dir_name)); var entry = m_arc.Dir.FirstOrDefault (e => e.Name.StartsWith (dir_name, StringComparison.InvariantCultureIgnoreCase));
if (null == entry) if (null == entry)
throw new DirectoryNotFoundException(); throw new DirectoryNotFoundException();
} }