Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Windows filepaths to lowercase and backslashes in mthelp #1380

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Programs/MiKTeX/mthelp/mthelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,25 @@ void MiKTeXHelp::ViewFile(const PathName& fileName)
#if defined(MIKTEX_WINDOWS)
if (viewer.empty())
{
// convert path to lowercase with backslashes to accommodate Windows programs that do not recognize other paths
string win32FileName = fileName.ToString();
std::transform(win32FileName.begin(), win32FileName.end(), win32FileName.begin(), [](char c) {
return std::tolower(c);
});
std::replace(win32FileName.begin(), win32FileName.end(), '/', '\\');

wchar_t szExecutable[BufferSizes::MaxPath];
HINSTANCE hInst = FindExecutableW(fileName.ToWideCharString().c_str(), L"C:\\", szExecutable);
if (hInst >= reinterpret_cast<HINSTANCE>(32))
{
viewer = StringUtil::WideCharToUTF8(szExecutable);
if (printOnly)
{
cout << Q_(PathName(szExecutable)) << ' ' << Q_(fileName) << endl;
cout << Q_(PathName(szExecutable)) << ' ' << Q_(win32FileName) << endl;
}
else
{
Process::Start(PathName(szExecutable), { PathName(szExecutable).GetFileNameWithoutExtension().ToString(), fileName.ToString() });
Process::Start(PathName(szExecutable), { PathName(szExecutable).GetFileNameWithoutExtension().ToString(), win32FileName });
}
return;
}
Expand Down