/// ------------------------------------------------------------------------------------ /// <summary> /// Try to match the given pathname to an existing file, playing whatever games are /// necessary with Unicode normalization. (See LT-8726.) /// </summary> /// <param name="sPathname">full pathname of a file</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static string ActualFilePath(string sPathname) { if (s_fileos.FileExists(sPathname)) { return(sPathname); } if (s_fileos.FileExists(sPathname.Normalize())) // NFC { return(sPathname.Normalize()); } if (s_fileos.FileExists(sPathname.Normalize(NormalizationForm.FormD))) // NFD { return(sPathname.Normalize(NormalizationForm.FormD)); } string sDir = Path.GetDirectoryName(sPathname); string sFile = Path.GetFileName(sPathname).Normalize().ToLowerInvariant(); if (!s_fileos.DirectoryExists(sDir)) { sDir = sDir.Normalize(); } if (!s_fileos.DirectoryExists(sDir)) { sDir = sDir.Normalize(NormalizationForm.FormD); } if (s_fileos.DirectoryExists(sDir)) { foreach (string sPath in s_fileos.GetFilesInDirectory(sDir)) { string sName = Path.GetFileName(sPath).Normalize().ToLowerInvariant(); if (sName == sFile) { return(sPath); } } } // nothing matches, so return the original pathname return(sPathname); }