【优化】path检查时严格检查文件大小写

main
walon 2022-03-27 16:44:06 +08:00
parent 82fbdb513f
commit 7bc489e15e
3 changed files with 23 additions and 3 deletions

View File

@ -183,7 +183,7 @@ namespace Luban.Client.Common.Net
private bool CheckSubResourceExists(string mainResFileName, string subResName)
{
s_logger.Debug("check resources main:{} sub:{}", mainResFileName, subResName);
if (!File.Exists(mainResFileName))
if (!FileUtil.IsFileExistsSenseCase(mainResFileName))
{
return false;
}
@ -236,7 +236,7 @@ namespace Luban.Client.Common.Net
}
else
{
tasks.Add(Task.Run(() => File.Exists(Path.Combine(root, f))));
tasks.Add(Task.Run(() => FileUtil.IsFileExistsSenseCase(Path.Combine(root, f))));
}
}

View File

@ -21,7 +21,7 @@ namespace Luban.Client.Common.Utils
public void AddOutputDir(string dir)
{
dir = dir.TrimEnd('/', '\\');
dir = Path.TrimEndingDirectorySeparator(dir);
_outputDirs.Add(dir);
}

View File

@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@ -49,6 +51,24 @@ namespace Luban.Common.Utils
return Combine(GetParent(rootFile), file);
}
public static bool IsFileExistsSenseCase(string path)
{
if (!File.Exists(path))
{
return false;
}
if (OperatingSystem.IsWindows())
{
var fileName = Path.GetFileName(path);
var files = Directory.GetFiles(Path.GetDirectoryName(path), fileName, new EnumerationOptions() { MatchCasing = MatchCasing.CaseSensitive });
return files.Length > 0;
}
else
{
return true;
}
}
/// <summary>
/// 忽略以 文件名以 '.' '_' '~' 开头的文件
/// </summary>