mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
some more LongPath handling
This commit is contained in:
parent
34ed9369ac
commit
e890580d16
@ -955,16 +955,10 @@ extern "C" bool FindIniFile()
|
||||
{
|
||||
bool bFound = false;
|
||||
|
||||
HPATHL hmod_pth = Path_Allocate(NULL);
|
||||
Path_GetModuleFilePath(hmod_pth);
|
||||
|
||||
HPATHL hdir_pth = Path_Allocate(Path_Get(hmod_pth));
|
||||
Path_RemoveFileSpec(hdir_pth);
|
||||
|
||||
HPATHL hdir_pth = Path_Allocate(NULL);
|
||||
Path_GetAppDirectory(hdir_pth);
|
||||
SetEnvironmentVariableW(NOTEPAD3_MODULE_DIR_ENV_VAR, Path_Get(hdir_pth));
|
||||
|
||||
Path_Release(hdir_pth);
|
||||
Path_Release(hmod_pth);
|
||||
|
||||
|
||||
if (Path_IsNotEmpty(Paths.IniFile)) {
|
||||
|
||||
@ -4558,35 +4558,49 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, LPCWSTR lpcwFilePath, WINI
|
||||
//
|
||||
void DialogFileBrowse(HWND hwnd)
|
||||
{
|
||||
WCHAR tchTemp[MAX_PATH] = { L'\0' };
|
||||
WCHAR tchParam[MAX_PATH] = { L'\0' };
|
||||
WCHAR tchExeFile[MAX_PATH] = { L'\0' };
|
||||
|
||||
if (StrIsNotEmpty(Settings2.FileBrowserPath)) {
|
||||
ExtractFirstArgument(Settings2.FileBrowserPath, tchExeFile, tchParam, COUNTOF(tchExeFile));
|
||||
ExpandEnvironmentStringsEx(tchExeFile, COUNTOF(tchExeFile));
|
||||
}
|
||||
if (StrStrI(tchExeFile, L"explorer.exe") && StrIsEmpty(tchParam)) {
|
||||
SendWMCommand(hwnd, IDM_FILE_EXPLORE_DIR);
|
||||
wchar_t* const param_buf = AllocMem((PATHLONG_MAX_CCH + 1) * sizeof(wchar_t), HEAP_ZERO_MEMORY);
|
||||
if (!param_buf) {
|
||||
return;
|
||||
}
|
||||
if (StrIsEmpty(tchExeFile)) {
|
||||
StringCchCopy(tchExeFile, COUNTOF(tchExeFile), Constants.FileBrowserMiniPath);
|
||||
|
||||
HPATHL hExeFile = Path_Allocate(NULL);
|
||||
wchar_t* const pth_buf = Path_WriteAccessBuf(hExeFile, PATHLONG_MAX_CCH);
|
||||
|
||||
if (StrIsNotEmpty(Settings2.FileBrowserPath)) {
|
||||
ExtractFirstArgument(Settings2.FileBrowserPath, pth_buf, param_buf, PATHLONG_MAX_CCH);
|
||||
Path_ExpandEnvStrings(hExeFile);
|
||||
}
|
||||
if (PathIsRelative(tchExeFile)) {
|
||||
PathGetAppDirectory(tchTemp, COUNTOF(tchTemp));
|
||||
PathAppend(tchTemp, tchExeFile);
|
||||
if (PathIsExistingFile(tchTemp)) {
|
||||
StringCchCopy(tchExeFile, COUNTOF(tchExeFile), tchTemp);
|
||||
Path_Sanitize(hExeFile);
|
||||
|
||||
if (StrStrIW(Path_Get(hExeFile), L"explorer.exe") && StrIsEmpty(param_buf)) {
|
||||
SendWMCommand(hwnd, IDM_FILE_EXPLORE_DIR);
|
||||
Path_Release(hExeFile);
|
||||
FreeMem(param_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Path_IsEmpty(hExeFile)) {
|
||||
Path_Reset(hExeFile, Constants.FileBrowserMiniPath);
|
||||
}
|
||||
|
||||
if (Path_IsRelative(hExeFile)) {
|
||||
HPATHL hTemp = Path_Allocate(NULL);
|
||||
Path_GetAppDirectory(hTemp);
|
||||
Path_Append(hTemp, hExeFile);
|
||||
if (Path_IsExistingFile(hTemp)) {
|
||||
Path_Swap(hExeFile, hTemp);
|
||||
}
|
||||
Path_Release(hTemp);
|
||||
}
|
||||
if (StrIsNotEmpty(tchParam) && Path_IsNotEmpty(Paths.CurrentFile)) {
|
||||
StringCchCat(tchParam, COUNTOF(tchParam), L" ");
|
||||
|
||||
if (StrIsNotEmpty(param_buf) && Path_IsNotEmpty(Paths.CurrentFile)) {
|
||||
StringCchCat(param_buf, PATHLONG_MAX_CCH, L" ");
|
||||
}
|
||||
|
||||
if (Path_IsNotEmpty(Paths.CurrentFile)) {
|
||||
HPATHL pthTmp = Path_Copy(Paths.CurrentFile);
|
||||
Path_QuoteSpaces(pthTmp);
|
||||
StringCchCat(tchParam, COUNTOF(tchParam), Path_Get(pthTmp));
|
||||
StringCchCat(param_buf, PATHLONG_MAX_CCH, Path_Get(pthTmp));
|
||||
Path_Release(pthTmp);
|
||||
}
|
||||
|
||||
@ -4594,8 +4608,8 @@ void DialogFileBrowse(HWND hwnd)
|
||||
sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOZONECHECKS;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = tchExeFile;
|
||||
sei.lpParameters = tchParam;
|
||||
sei.lpFile = Path_Get(hExeFile);
|
||||
sei.lpParameters = param_buf;
|
||||
sei.lpDirectory = NULL;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
ShellExecuteEx(&sei);
|
||||
@ -4603,6 +4617,9 @@ void DialogFileBrowse(HWND hwnd)
|
||||
if ((INT_PTR)sei.hInstApp < 32) {
|
||||
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BROWSE);
|
||||
}
|
||||
|
||||
Path_Release(hExeFile);
|
||||
FreeMem(param_buf);
|
||||
}
|
||||
|
||||
|
||||
@ -4771,7 +4788,7 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
|
||||
}
|
||||
|
||||
// grepWin arguments
|
||||
WCHAR tchParams[2*MAX_PATH] = { L'\0' };
|
||||
WCHAR tchParams[MAX_PATH<<2] = { L'\0' };
|
||||
|
||||
if (Path_IsExistingFile(hgrepwin_ini_pth)) {
|
||||
// relative grepWinNP3.ini path (for shorter cmdline)
|
||||
|
||||
@ -7277,24 +7277,21 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
|
||||
} else if (operation & OPEN_WITH_BROWSER) { // open in web browser or associated application
|
||||
|
||||
// TODO: §§§ MAX_PATH limit §§§ @@@!
|
||||
WCHAR wchDirectory[MAX_PATH] = { L'\0' };
|
||||
HPATHL hDirectory = Path_Allocate(NULL);
|
||||
|
||||
if (UrlIsFileUrl(szTextW)) {
|
||||
// ShellExecuteEx() will handle file-system path correctly for "file://" protocol
|
||||
StringCchCopy(szUnEscW, COUNTOF(szUnEscW), chkPreFix);
|
||||
dCch -= (DWORD)lenPfx;
|
||||
PathCreateFromUrl(szTextW, &szUnEscW[lenPfx], &dCch, 0);
|
||||
StringCchCopy(wchDirectory, COUNTOF(wchDirectory), szUnEscW);
|
||||
PathRemoveFileSpec(wchDirectory);
|
||||
Path_Reset(hDirectory, szUnEscW);
|
||||
Path_RemoveFileSpec(hDirectory);
|
||||
} else {
|
||||
UrlUnescapeEx(szTextW, szUnEscW, &dCch);
|
||||
}
|
||||
if (StrIsEmpty(wchDirectory) && Path_IsNotEmpty(Paths.CurrentFile)) {
|
||||
HPATHL hdir = Path_Copy(Paths.CurrentFile);
|
||||
Path_RemoveFileSpec(hdir);
|
||||
StringCchCopy(wchDirectory, COUNTOF(wchDirectory), Path_Get(hdir));
|
||||
Path_Release(hdir);
|
||||
if (Path_IsEmpty(hDirectory) && Path_IsNotEmpty(Paths.CurrentFile)) {
|
||||
Path_Reset(hDirectory, Path_Get(Paths.CurrentFile));
|
||||
Path_RemoveFileSpec(hDirectory);
|
||||
}
|
||||
|
||||
if (StrIsNotEmpty(Settings2.HyperlinkShellExURLWithApp)) {
|
||||
@ -7307,7 +7304,7 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = Settings2.HyperlinkShellExURLWithApp;
|
||||
sei.lpParameters = StrIsNotEmpty(lpParams) ? lpParams : szUnEscW;
|
||||
sei.lpDirectory = wchDirectory;
|
||||
sei.lpDirectory = Path_Get(hDirectory);
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
|
||||
bHandled = ShellExecuteEx(&sei);
|
||||
@ -7323,10 +7320,12 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
sei.lpVerb = lpVerb;
|
||||
sei.lpFile = szUnEscW;
|
||||
sei.lpParameters = NULL;
|
||||
sei.lpDirectory = wchDirectory;
|
||||
sei.lpDirectory = Path_Get(hDirectory);
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
bHandled = ShellExecuteEx(&sei);
|
||||
}
|
||||
|
||||
Path_Release(hDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11330,9 +11329,9 @@ void SetNotifyIconTitle(HWND hwnd)
|
||||
nid.uFlags = NIF_TIP;
|
||||
nid.szTip[0] = L'\0';
|
||||
|
||||
WCHAR tchTitle[128] = { L'\0' };
|
||||
WCHAR tchTitle[256] = { L'\0' };
|
||||
if (StrIsNotEmpty(s_wchTitleExcerpt)) {
|
||||
WCHAR tchFormat[32] = { L'\0' };
|
||||
WCHAR tchFormat[128] = { L'\0' };
|
||||
GetLngString(IDS_MUI_TITLEEXCERPT,tchFormat,COUNTOF(tchFormat));
|
||||
StringCchPrintf(tchTitle,COUNTOF(tchTitle),tchFormat,s_wchTitleExcerpt);
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ bool PTHAPI Path_Append(HPATHL hpth_in_out, const HPATHL hmore)
|
||||
|
||||
const wchar_t* const wchm = PathGet(hmore);
|
||||
wchar_t* const wbuf = StrgWriteAccessBuf(hstr_io, hstr_len + hmore_len + PATHLONG_PREFIX_LEN + 2);
|
||||
size_t const cch = StrgGetAllocLength(hstr_io);
|
||||
size_t const cch = StrgGetAllocLength(hstr_io);
|
||||
|
||||
// append directory separator
|
||||
if (hstr_len > 0) {
|
||||
@ -744,7 +744,7 @@ bool PTHAPI Path_Append(HPATHL hpth_in_out, const HPATHL hmore)
|
||||
// wbuf[1] = L'\0';
|
||||
//}
|
||||
|
||||
StringCchCatW(wbuf, cch, PathGet(hmore));
|
||||
StringCchCatW(wbuf, cch, wchm);
|
||||
StrgSanitize(hstr_io);
|
||||
|
||||
Path_Canonicalize(hpth_in_out);
|
||||
@ -1531,8 +1531,7 @@ bool PTHAPI Path_CanonicalizeEx(HPATHL hpth_in_out)
|
||||
if (_Path_IsRelative(hpth_in_out))
|
||||
{
|
||||
HPATHL hmod_pth = Path_Allocate(NULL);
|
||||
Path_GetModuleFilePath(hmod_pth);
|
||||
Path_RemoveFileSpec(hmod_pth);
|
||||
Path_GetAppDirectory(hmod_pth);
|
||||
Path_Append(hmod_pth, hpth_in_out);
|
||||
res = Path_Canonicalize(hmod_pth);
|
||||
Path_Swap(hpth_in_out, hmod_pth);
|
||||
@ -1682,7 +1681,6 @@ void PTHAPI Path_GetAppDirectory(HPATHL hpth_out)
|
||||
happdir_path = Path_Allocate(NULL);
|
||||
Path_GetModuleFilePath(happdir_path);
|
||||
Path_RemoveFileSpec(happdir_path);
|
||||
Path_Canonicalize(happdir_path);
|
||||
}
|
||||
|
||||
Path_Reset(hpth_out, PathGet(happdir_path));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user