Add the possibility for opening a shortcut file if change file ext

Do not recognize files without lnk-extension as Windows shortcuts.

Fix also https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15211#issuecomment-2156495651

Fix #9643, fix #11089, fix #10139, close #15364
pull/15371/head^2
xomx 2024-06-26 19:17:31 +02:00 committed by Don Ho
parent d0f5742664
commit 982f52224c
2 changed files with 10 additions and 1 deletions

View File

@ -1549,6 +1549,9 @@ bool isUnsupportedFileName(const generic_string& fileName)
if (pos != std::string::npos)
fileNameOnly = fileNameOnly.substr(pos + 1);
// upperize because the std::find is case sensitive unlike the Windows OS filesystem
std::transform(fileNameOnly.begin(), fileNameOnly.end(), fileNameOnly.begin(), ::towupper);
const std::vector<generic_string> reservedWin32NamespaceDeviceList{
TEXT("CON"), TEXT("PRN"), TEXT("AUX"), TEXT("NUL"),
TEXT("COM1"), TEXT("COM2"), TEXT("COM3"), TEXT("COM4"), TEXT("COM5"), TEXT("COM6"), TEXT("COM7"), TEXT("COM8"), TEXT("COM9"),

View File

@ -126,8 +126,14 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
return EXIT_SUCCESS;
}
bool resolveLinkFile(generic_string& linkFilePath)
bool resolveLinkFile(std::wstring& linkFilePath)
{
// upperize for the following comparison because the ends_with is case sensitive unlike the Windows OS filesystem
std::wstring linkFilePathUp = linkFilePath;
std::transform(linkFilePathUp.begin(), linkFilePathUp.end(), linkFilePathUp.begin(), ::towupper);
if (!linkFilePathUp.ends_with(L".LNK"))
return false; // we will not check the renamed shortcuts like "file.lnk.txt"
bool isResolved = false;
IShellLink* psl = nullptr;