some more LongPath handling

This commit is contained in:
METANEOCORTEX\Kotti 2021-09-23 02:06:32 +02:00
parent ed0a440d40
commit c643b7ea1c
2 changed files with 25 additions and 25 deletions

View File

@ -104,16 +104,17 @@
//
// ============================================================================
#if !defined(WINVER)
#define WINVER 0x602 /*_WIN32_WINNT_WIN8*/
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0601 /*_WIN32_WINNT_WIN7*/
#endif
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x602 /*_WIN32_WINNT_WIN8*/
#ifndef WINVER
#define WINVER 0x0601 /*_WIN32_WINNT_WIN7*/
#endif
#if !defined(NTDDI_VERSION)
#define NTDDI_VERSION 0x06020000 /*NTDDI_WIN7*/
#ifndef NTDDI_VERSION
#define NTDDI_VERSION 0x06010000 /*NTDDI_WIN7*/
#endif
#define NOMINMAX
#define VC_EXTRALEAN 1
#define WIN32_LEAN_AND_MEAN 1
@ -125,10 +126,6 @@
#include <strsafe.h>
#include <fileapi.h>
//~ Win8.1+ only:
//~#define PATHCCH_NO_DEPRECATE 1 // <- get rid of this!
//~#include <pathcch.h>
// get rid of this:
#include <shlobj.h>
#include <shellapi.h>
@ -136,9 +133,11 @@
#include "PathLib.h"
//~ Win8.1+ only:
//~#pragma comment(linker, "/defaultlib:Pathcch")
//~ Win8.1+ only:
//~#define PATHCCH_NO_DEPRECATE 1 // <- get rid of this!
//~#include <pathcch.h>
//~#pragma comment(linker, "/defaultlib:Pathcch")
/**************************************************/

View File

@ -932,12 +932,12 @@ bool Style_ImportFromFile(const WCHAR* szFile)
bool const bHaveFileResource = StrIsNotEmpty(szFile);
bool bIsStdIniFile = false;
if (bHaveFileResource) {
WCHAR szFilePathNorm[MAX_PATH] = { L'\0' };
StringCchCopy(szFilePathNorm, COUNTOF(szFilePathNorm), szFile);
NormalizePathEx(szFilePathNorm, COUNTOF(szFilePathNorm), Path_Get(Paths.ModuleDirectory), true, false);
if (StringCchCompareXI(szFilePathNorm, Path_Get(Paths.IniFile)) == 0) {
HPATHL hpth = Path_Allocate(szFile);
Path_NormalizeEx(hpth, Paths.ModuleDirectory, true, false);
if (StringCchCompareXI(Path_Get(hpth), Path_Get(Paths.IniFile)) == 0) {
bIsStdIniFile = true;
}
Path_Release(hpth);
}
bool bOpendByMe = false;
@ -1157,14 +1157,13 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
return false;
}
WCHAR szFilePathNorm[MAX_PATH] = { L'\0' };
StringCchCopy(szFilePathNorm, COUNTOF(szFilePathNorm), szFile);
NormalizePathEx(szFilePathNorm, COUNTOF(szFilePathNorm), Path_Get(Paths.ModuleDirectory), true, false);
HPATHL hpth = Path_Allocate(szFile);
Path_NormalizeEx(hpth, Paths.ModuleDirectory, true, false);
bool ok = false;
// special handling of standard .ini-file
if (StringCchCompareXI(szFilePathNorm, Path_Get(Paths.IniFile)) == 0) {
if (StringCchCompareXI(Path_Get(hpth), Path_Get(Paths.IniFile)) == 0) {
bool bOpendByMe = false;
if (OpenSettingsFile(&bOpendByMe)) {
Style_ToIniSection(bForceAll);
@ -1172,9 +1171,9 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
ok = CloseSettingsFile(true, bOpendByMe);
}
} else {
if (StrIsNotEmpty(szFilePathNorm)) {
if (!PathIsExistingFile(szFilePathNorm)) {
HANDLE hFile = CreateFile(szFilePathNorm,
if (Path_IsNotEmpty(hpth)) {
if (!Path_IsExistingFile(hpth)) {
HANDLE hFile = CreateFile(Path_Get(hpth),
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (IS_VALID_HANDLE(hFile)) {
@ -1182,14 +1181,15 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
}
}
ResetIniFileCache();
if (LoadIniFileCache(szFilePathNorm)) {
if (LoadIniFileCache(Path_Get(hpth))) {
Style_ToIniSection(bForceAll);
Style_FileExtToIniSection(bForceAll);
ok = SaveIniFileCache(szFilePathNorm);
ok = SaveIniFileCache(Path_Get(hpth));
ResetIniFileCache();
}
}
}
Path_Release(hpth);
return ok;
}
@ -2299,6 +2299,7 @@ PEDITLEXER Style_MatchLexer(LPCWSTR lpszMatch, bool bCheckNames)
PEDITLEXER Style_RegExMatchLexer(LPCWSTR lpszFileName)
{
if (StrIsNotEmpty(lpszFileName)) {
char chFilePath[MAX_PATH << 1] = { '\0' };
WideCharToMultiByteEx(CP_UTF8, 0, lpszFileName, -1, chFilePath, COUNTOF(chFilePath), NULL, NULL);