mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+rfc: some LongPath-Lib refactorings
This commit is contained in:
parent
b19a3f3ed6
commit
09208d9dd8
@ -270,9 +270,9 @@ extern "C" bool ResetIniFileCache()
|
||||
}
|
||||
|
||||
|
||||
extern "C" bool LoadIniFileCache(LPCWSTR lpIniFilePath)
|
||||
extern "C" bool LoadIniFileCache(const HPATHL hpthIniFile)
|
||||
{
|
||||
if (StrIsEmpty(lpIniFilePath) || !PathIsExistingFile(lpIniFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile) || !Path_IsExistingFile(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ extern "C" bool LoadIniFileCache(LPCWSTR lpIniFilePath)
|
||||
s_INI.SetMultiLine(s_bUseMultiLine);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hIniFile = AcquireReadFileLock(lpIniFilePath, ovrLpd);
|
||||
HANDLE hIniFile = AcquireReadFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
|
||||
if (!IS_VALID_HANDLE(hIniFile)) {
|
||||
return false;
|
||||
@ -300,14 +300,14 @@ extern "C" bool IsIniFileCached()
|
||||
}
|
||||
|
||||
|
||||
extern "C" bool SaveIniFileCache(LPCWSTR lpIniFilePath)
|
||||
extern "C" bool SaveIniFileCache(const HPATHL hpthIniFile)
|
||||
{
|
||||
if (!s_bIniFileCacheLoaded || StrIsEmpty(lpIniFilePath)) {
|
||||
if (!s_bIniFileCacheLoaded || Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hIniFile = AcquireWriteFileLock(lpIniFilePath, ovrLpd);
|
||||
HANDLE hIniFile = AcquireWriteFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
|
||||
if (!IS_VALID_HANDLE(hIniFile)) {
|
||||
return false;
|
||||
@ -336,7 +336,7 @@ extern "C" bool OpenSettingsFile(bool* keepCached)
|
||||
|
||||
if (!IsIniFileCached()) {
|
||||
ResetIniFileCache();
|
||||
LoadIniFileCache(Path_Get(Paths.IniFile));
|
||||
LoadIniFileCache(Paths.IniFile);
|
||||
if (keepCached != NULL) {
|
||||
*keepCached = false;
|
||||
}
|
||||
@ -360,7 +360,7 @@ extern "C" bool CloseSettingsFile(bool bSaveChanges, bool keepCached)
|
||||
if (!IsIniFileCached()) {
|
||||
return false;
|
||||
}
|
||||
bool const bSaved = bSaveChanges ? SaveIniFileCache(Path_Get(Paths.IniFile)) : false;
|
||||
bool const bSaved = bSaveChanges ? SaveIniFileCache(Paths.IniFile) : false;
|
||||
if (!keepCached) {
|
||||
ResetIniFileCache();
|
||||
}
|
||||
@ -544,10 +544,10 @@ extern "C" bool IniClearAllSections(LPCWSTR lpPrefix, bool bRemoveEmpty)
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
|
||||
extern "C" size_t IniFileGetString(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
|
||||
LPWSTR lpReturnedString, size_t cchReturnedString)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
StringCchCopy(lpReturnedString, cchReturnedString, lpDefault);
|
||||
return StringCchLenW(lpReturnedString, cchReturnedString);
|
||||
}
|
||||
@ -555,7 +555,7 @@ extern "C" size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LP
|
||||
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireReadFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireReadFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
StringCchCopy(lpReturnedString, cchReturnedString, lpDefault);
|
||||
return StringCchLenW(lpReturnedString, cchReturnedString);
|
||||
@ -576,9 +576,9 @@ extern "C" size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LP
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString)
|
||||
extern "C" bool IniFileSetString(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -586,7 +586,7 @@ extern "C" bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCW
|
||||
Ini.SetSpaces(s_bSetSpaces);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireWriteFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireWriteFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return false;
|
||||
}
|
||||
@ -606,16 +606,16 @@ extern "C" bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCW
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" int IniFileGetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iDefault)
|
||||
extern "C" int IniFileGetInt(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iDefault)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return iDefault;
|
||||
}
|
||||
|
||||
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireReadFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireReadFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return iDefault;
|
||||
}
|
||||
@ -634,9 +634,9 @@ extern "C" int IniFileGetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileSetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iValue)
|
||||
extern "C" bool IniFileSetInt(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iValue)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -644,7 +644,7 @@ extern "C" bool IniFileSetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
|
||||
Ini.SetSpaces(s_bSetSpaces);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireWriteFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireWriteFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return false;
|
||||
}
|
||||
@ -661,16 +661,16 @@ extern "C" bool IniFileSetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileGetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bDefault)
|
||||
extern "C" bool IniFileGetBool(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bDefault)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return bDefault;
|
||||
}
|
||||
|
||||
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireReadFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireReadFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return bDefault;
|
||||
}
|
||||
@ -689,9 +689,9 @@ extern "C" bool IniFileGetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bValue)
|
||||
extern "C" bool IniFileSetBool(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bValue)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -699,7 +699,7 @@ extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
|
||||
Ini.SetSpaces(s_bSetSpaces);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireWriteFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireWriteFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return false;
|
||||
}
|
||||
@ -716,9 +716,9 @@ extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty)
|
||||
extern "C" bool IniFileDelete(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -726,7 +726,7 @@ extern "C" bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
|
||||
Ini.SetSpaces(s_bSetSpaces);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireWriteFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireWriteFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return false;
|
||||
}
|
||||
@ -743,16 +743,16 @@ extern "C" bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
|
||||
// ============================================================================
|
||||
|
||||
|
||||
extern "C" bool IniFileIterateSection(LPCWSTR lpFilePath, LPCWSTR lpSectionName, IterSectionFunc_t callBack)
|
||||
extern "C" bool IniFileIterateSection(const HPATHL hpthIniFile, LPCWSTR lpSectionName, IterSectionFunc_t callBack)
|
||||
{
|
||||
if (StrIsEmpty(lpFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
|
||||
|
||||
OVERLAPPED ovrLpd = { 0 };
|
||||
HANDLE hFile = AcquireReadFileLock(lpFilePath, ovrLpd);
|
||||
HANDLE hFile = AcquireReadFileLock(Path_Get(hpthIniFile), ovrLpd);
|
||||
if (!IS_VALID_HANDLE(hFile)) {
|
||||
return false;
|
||||
}
|
||||
@ -782,15 +782,15 @@ extern "C" bool IniFileIterateSection(LPCWSTR lpFilePath, LPCWSTR lpSectionName,
|
||||
//
|
||||
// AddFilePathToRecentDocs()
|
||||
//
|
||||
extern "C" void AddFilePathToRecentDocs(LPCWSTR szFilePath)
|
||||
extern "C" void AddFilePathToRecentDocs(const HPATHL hpthIniFile)
|
||||
{
|
||||
if (StrIsEmpty(szFilePath)) {
|
||||
if (Path_IsEmpty(hpthIniFile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Flags.ShellUseSystemMRU) {
|
||||
#if TRUE
|
||||
SHAddToRecentDocs(SHARD_PATHW, szFilePath);
|
||||
SHAddToRecentDocs(SHARD_PATHW, Path_Get(hpthIniFile));
|
||||
#else
|
||||
(void)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE);
|
||||
|
||||
@ -932,7 +932,7 @@ static bool _HandleIniFileRedirect(LPCWSTR lpszSecName, LPCWSTR lpszKeyName, HPA
|
||||
if (Path_IsExistingFile(hpth_in_out)) {
|
||||
HPATHL hredirect = Path_Allocate(NULL);
|
||||
LPWSTR const buf = Path_WriteAccessBuf(hredirect, PATHLONG_MAX_CCH);
|
||||
if (IniFileGetString(Path_Get(hpth_in_out), lpszSecName, lpszKeyName, L"", buf, PATHLONG_MAX_CCH)) {
|
||||
if (IniFileGetString(hpth_in_out, lpszSecName, lpszKeyName, L"", buf, PATHLONG_MAX_CCH)) {
|
||||
Path_Sanitize(hredirect);
|
||||
Path_FreeExtra(hredirect, 0);
|
||||
if (_CheckAndSetIniFile(hredirect)) {
|
||||
@ -2437,23 +2437,23 @@ bool MRU_AddFile(LPMRULIST pmru, LPCWSTR pszFile, bool bRelativePath, bool bUnex
|
||||
pmru->iSelAnchPos[i] = pmru->iSelAnchPos[i - 1];
|
||||
pmru->pszBookMarks[i] = pmru->pszBookMarks[i - 1];
|
||||
}
|
||||
if (bRelativePath) {
|
||||
HPATHL const hpth = Path_Allocate(pszFile);
|
||||
Path_RelativeToApp(hpth, true, true, bUnexpandMyDocs);
|
||||
pmru->pszItems[0] = StrDupW(Path_Get(hpth)); // LocalAlloc()
|
||||
Path_Release(hpth);
|
||||
} else {
|
||||
pmru->pszItems[0] = StrDupW(pszFile); // LocalAlloc()
|
||||
}
|
||||
|
||||
HPATHL const hpth = Path_Allocate(pszFile);
|
||||
if (bRelativePath) {
|
||||
Path_RelativeToApp(hpth, true, true, bUnexpandMyDocs);
|
||||
}
|
||||
pmru->pszItems[0] = StrDupW(Path_Get(hpth)); // LocalAlloc()
|
||||
pmru->iEncoding[0] = iEnc;
|
||||
pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : -1);
|
||||
pmru->iSelAnchPos[0] = (Settings.PreserveCaretPos ? iSelAnc : -1);
|
||||
pmru->pszBookMarks[0] = (pszBookMarks ? StrDupW(pszBookMarks) : NULL); // LocalAlloc()
|
||||
|
||||
if (!bAlreadyInList) {
|
||||
AddFilePathToRecentDocs(pszFile);
|
||||
AddFilePathToRecentDocs(hpth);
|
||||
}
|
||||
|
||||
Path_Release(hpth);
|
||||
|
||||
return bAlreadyInList;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -49,9 +49,9 @@ bool ResetTmpCache();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool LoadIniFileCache(LPCWSTR lpIniFilePath);
|
||||
bool LoadIniFileCache(const HPATHL hpthIniFile);
|
||||
bool IsIniFileCached();
|
||||
bool SaveIniFileCache(LPCWSTR lpIniFilePath);
|
||||
bool SaveIniFileCache(const HPATHL hpthIniFile);
|
||||
bool ResetIniFileCache();
|
||||
|
||||
size_t IniSectionGetString(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
|
||||
@ -105,15 +105,15 @@ bool IniClearAllSections(LPCWSTR lpPrefix, bool bRemoveEmpty);
|
||||
// open file , get/set value, save(set) file
|
||||
// ==========================================
|
||||
|
||||
size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
|
||||
size_t IniFileGetString(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
|
||||
LPWSTR lpReturnedString, size_t cchReturnedString);
|
||||
bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString);
|
||||
bool IniFileSetString(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString);
|
||||
|
||||
int IniFileGetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iDefault);
|
||||
bool IniFileSetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iValue);
|
||||
int IniFileGetInt(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iDefault);
|
||||
bool IniFileSetInt(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iValue);
|
||||
|
||||
bool IniFileGetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bDefault);
|
||||
bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bValue);
|
||||
bool IniFileGetBool(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bDefault);
|
||||
bool IniFileSetBool(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bValue);
|
||||
|
||||
// IniFileDeleteValue():
|
||||
//
|
||||
@ -124,16 +124,16 @@ bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName
|
||||
// bRemoveEmpty If the section is empty after this key has
|
||||
// been deleted, should the empty section be removed ?
|
||||
//
|
||||
bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty);
|
||||
bool IniFileDelete(const HPATHL hpthIniFile, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty);
|
||||
|
||||
// IniFileIterateSection():
|
||||
//
|
||||
typedef void (CALLBACK* IterSectionFunc_t)(LPCWSTR key, LPCWSTR value);
|
||||
bool IniFileIterateSection(LPCWSTR lpFilePath, LPCWSTR lpSectionName, IterSectionFunc_t callBack);
|
||||
bool IniFileIterateSection(const HPATHL hpthIniFile, LPCWSTR lpSectionName, IterSectionFunc_t callBack);
|
||||
|
||||
//==== MRU Functions ==========================================================
|
||||
|
||||
void AddFilePathToRecentDocs(LPCWSTR szFilePath);
|
||||
void AddFilePathToRecentDocs(const HPATHL hpthIniFile);
|
||||
//void ClearDestinationsOnRecentDocs();
|
||||
|
||||
LPMRULIST MRU_Create(LPCWSTR pszRegKey, int iFlags, int iSize);
|
||||
|
||||
@ -344,7 +344,7 @@ CASE_WM_CTLCOLOR_SET:
|
||||
case IDTRYAGAIN:
|
||||
case IDCONTINUE:
|
||||
if (IsButtonChecked(hwnd, IDC_INFOBOXCHECK) && StrIsNotEmpty(lpMsgBox->lpstrSetting) && Globals.bCanSaveIniFile) {
|
||||
IniFileSetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpMsgBox->lpstrSetting, LOWORD(wParam));
|
||||
IniFileSetInt(Paths.IniFile, Constants.SectionSuppressedMessages, lpMsgBox->lpstrSetting, LOWORD(wParam));
|
||||
}
|
||||
case IDNO:
|
||||
case IDABORT:
|
||||
@ -378,7 +378,7 @@ CASE_WM_CTLCOLOR_SET:
|
||||
|
||||
LONG InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...)
|
||||
{
|
||||
int const iMode = StrIsEmpty(lpstrSetting) ? 0 : IniFileGetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, 0);
|
||||
int const iMode = StrIsEmpty(lpstrSetting) ? 0 : IniFileGetInt(Paths.IniFile, Constants.SectionSuppressedMessages, lpstrSetting, 0);
|
||||
|
||||
if (Settings.DialogsLayoutRTL) {
|
||||
uType |= MB_RTLREADING;
|
||||
@ -398,7 +398,7 @@ LONG InfoBoxLng(UINT uType, LPCWSTR lpstrSetting, UINT uidMsg, ...)
|
||||
|
||||
default:
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, lpstrSetting, false);
|
||||
IniFileDelete(Paths.IniFile, Constants.SectionSuppressedMessages, lpstrSetting, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4698,7 +4698,7 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
|
||||
}
|
||||
|
||||
ResetIniFileCache();
|
||||
if (CreateIniFile(hGrepWinIniPath, NULL) && LoadIniFileCache(Path_Get(hGrepWinIniPath))) {
|
||||
if (CreateIniFile(hGrepWinIniPath, NULL) && LoadIniFileCache(hGrepWinIniPath)) {
|
||||
// preserve [global] user settings from last call
|
||||
const WCHAR* const globalSection = L"global";
|
||||
|
||||
@ -4774,7 +4774,7 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern)
|
||||
// search pattern
|
||||
IniSectionSetString(globalSection, L"searchfor", searchPattern);
|
||||
|
||||
SaveIniFileCache(Path_Get(hGrepWinIniPath));
|
||||
SaveIniFileCache(hGrepWinIniPath);
|
||||
ResetIniFileCache();
|
||||
|
||||
}
|
||||
@ -4966,7 +4966,7 @@ void SetWindowTitle(HWND hwnd, const HPATHL pthFilePath, int iFormat,
|
||||
else if (Path_IsNotEmpty(pthFilePath)) {
|
||||
|
||||
if (iFormat < 2) {
|
||||
if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath) != 0) {
|
||||
if (Path_StrgComparePath(s_pthCachedFilePath, pthFilePath, Paths.WorkingDirectory) != 0) {
|
||||
Path_Reset(s_pthCachedFilePath, Path_Get(pthFilePath));
|
||||
Path_GetDisplayName(s_wchCachedDisplayName, COUNTOF(s_wchCachedDisplayName), s_pthCachedFilePath, s_szUntitled);
|
||||
}
|
||||
|
||||
@ -189,9 +189,9 @@ void SetMuiLanguage(const unsigned muiLngIndex) {
|
||||
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
if (StringCchCompareXIW(Settings2.PreferredLanguageLocaleName, Default_PreferredLanguageLocaleName) != 0) {
|
||||
IniFileSetString(Path_Get(Paths.IniFile), Constants.Settings2_Section, SettingName, Settings2.PreferredLanguageLocaleName);
|
||||
IniFileSetString(Paths.IniFile, Constants.Settings2_Section, SettingName, Settings2.PreferredLanguageLocaleName);
|
||||
} else {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings2_Section, SettingName, false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings2_Section, SettingName, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -413,9 +413,9 @@ unsigned LoadLanguageResources(LPCWSTR pLocaleName) {
|
||||
|
||||
const WCHAR *const suprMsg = L"MsgPrefLanguageNotAvailable";
|
||||
InfoBoxLng(MB_ICONWARNING, suprMsg, IDS_WARN_PREF_LNG_NOT_AVAIL, pLocaleName);
|
||||
int const noMsg = IniFileGetInt(Path_Get(Paths.IniFile), Constants.SectionSuppressedMessages, suprMsg, 0);
|
||||
int const noMsg = IniFileGetInt(Paths.IniFile, Constants.SectionSuppressedMessages, suprMsg, 0);
|
||||
if (noMsg && Globals.bCanSaveIniFile) {
|
||||
IniFileSetString(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"PreferredLanguageLocaleName", MUI_LanguageDLLs[iInternalLngIndex].LocaleName);
|
||||
IniFileSetString(Paths.IniFile, Constants.Settings2_Section, L"PreferredLanguageLocaleName", MUI_LanguageDLLs[iInternalLngIndex].LocaleName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,11 +433,11 @@ unsigned LoadLanguageResources(LPCWSTR pLocaleName) {
|
||||
WCHAR tchDefaultStrg[MIDSZ_BUFFER] = { L'\0' };
|
||||
|
||||
GetLngString(IDS_MUI_STATUSBAR_PREFIXES, tchDefaultStrg, COUNTOF(tchDefaultStrg));
|
||||
IniFileGetString(Path_Get(Paths.IniFile), StatusBar_Section, L"SectionPrefixes", tchDefaultStrg, tchStatusBar, COUNTOF(tchStatusBar));
|
||||
IniFileGetString(Paths.IniFile, StatusBar_Section, L"SectionPrefixes", tchDefaultStrg, tchStatusBar, COUNTOF(tchStatusBar));
|
||||
ReadStrgsFromCSV(tchStatusBar, g_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_");
|
||||
|
||||
GetLngString(IDS_MUI_STATUSBAR_POSTFIXES, tchDefaultStrg, COUNTOF(tchDefaultStrg));
|
||||
IniFileGetString(Path_Get(Paths.IniFile), StatusBar_Section, L"SectionPostfixes", tchDefaultStrg, tchStatusBar, COUNTOF(tchStatusBar));
|
||||
IniFileGetString(Paths.IniFile, StatusBar_Section, L"SectionPostfixes", tchDefaultStrg, tchStatusBar, COUNTOF(tchStatusBar));
|
||||
ReadStrgsFromCSV(tchStatusBar, g_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_");
|
||||
|
||||
return iLngIndex;
|
||||
|
||||
@ -1019,7 +1019,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
Globals.bIniFileFromScratch = (dwFileSize == 0UL);
|
||||
if (Globals.bIniFileFromScratch && Globals.bCanSaveIniFile) {
|
||||
// Set at least Application Name Section
|
||||
IniFileSetString(Path_Get(Paths.IniFile), _W(SAPPNAME), NULL, NULL);
|
||||
IniFileSetString(Paths.IniFile, _W(SAPPNAME), NULL, NULL);
|
||||
}
|
||||
LoadSettings();
|
||||
|
||||
@ -2527,7 +2527,7 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
Path_Reset(g_tchToolbarBitmap, Path_Get(hfile_pth));
|
||||
Path_RelativeToApp(g_tchToolbarBitmap, true, true, true);
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
IniFileSetString(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapDefault", Path_Get(g_tchToolbarBitmap));
|
||||
IniFileSetString(Paths.IniFile, L"Toolbar Images", L"BitmapDefault", Path_Get(g_tchToolbarBitmap));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2546,10 +2546,10 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
if (Path_IsExistingFile(hfile_pth)) {
|
||||
Path_Reset(g_tchToolbarBitmapHot, Path_Get(hfile_pth));
|
||||
Path_RelativeToApp(g_tchToolbarBitmapHot, true, true, true);
|
||||
IniFileSetString(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapHot", Path_Get(g_tchToolbarBitmapHot));
|
||||
IniFileSetString(Paths.IniFile, L"Toolbar Images", L"BitmapHot", Path_Get(g_tchToolbarBitmapHot));
|
||||
} else {
|
||||
Path_Reset(g_tchToolbarBitmapHot, L"");
|
||||
IniFileDelete(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapHot", false);
|
||||
IniFileDelete(Paths.IniFile, L"Toolbar Images", L"BitmapHot", false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2561,10 +2561,10 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
if (Path_IsExistingFile(hfile_pth)) {
|
||||
Path_Reset(g_tchToolbarBitmapDisabled, Path_Get(hfile_pth));
|
||||
Path_RelativeToApp(g_tchToolbarBitmapDisabled, true, true, true);
|
||||
IniFileSetString(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapDisabled", Path_Get(g_tchToolbarBitmapDisabled));
|
||||
IniFileSetString(Paths.IniFile, L"Toolbar Images", L"BitmapDisabled", Path_Get(g_tchToolbarBitmapDisabled));
|
||||
} else {
|
||||
Path_Reset(g_tchToolbarBitmapDisabled, L"");
|
||||
IniFileDelete(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapDisabled", false);
|
||||
IniFileDelete(Paths.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2572,8 +2572,8 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
res = true;
|
||||
|
||||
} else {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapHot", false);
|
||||
IniFileDelete(Path_Get(Paths.IniFile), L"Toolbar Images", L"BitmapDisabled", false);
|
||||
IniFileDelete(Paths.IniFile, L"Toolbar Images", L"BitmapHot", false);
|
||||
IniFileDelete(Paths.IniFile, L"Toolbar Images", L"BitmapDisabled", false);
|
||||
}
|
||||
|
||||
Path_Release(hfile_pth);
|
||||
@ -5992,9 +5992,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
Flags.bReuseWindow = !Flags.bReuseWindow; // reverse
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
if (Flags.bReuseWindow != DefaultFlags.bReuseWindow) {
|
||||
IniFileSetBool(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"ReuseWindow", Flags.bReuseWindow);
|
||||
IniFileSetBool(Paths.IniFile, Constants.Settings2_Section, L"ReuseWindow", Flags.bReuseWindow);
|
||||
} else {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"ReuseWindow", false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings2_Section, L"ReuseWindow", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6006,9 +6006,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
Flags.bSingleFileInstance = !Flags.bSingleFileInstance; // reverse
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
if (Flags.bSingleFileInstance != DefaultFlags.bSingleFileInstance) {
|
||||
IniFileSetInt(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"SingleFileInstance", Flags.bSingleFileInstance);
|
||||
IniFileSetInt(Paths.IniFile, Constants.Settings2_Section, L"SingleFileInstance", Flags.bSingleFileInstance);
|
||||
} else {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"SingleFileInstance", false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings2_Section, L"SingleFileInstance", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6186,9 +6186,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
Settings.SaveSettings = !Settings.SaveSettings;
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
if (Settings.SaveSettings == Defaults.SaveSettings) {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings_Section, L"SaveSettings", false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings_Section, L"SaveSettings", false);
|
||||
} else {
|
||||
IniFileSetBool(Path_Get(Paths.IniFile), Constants.Settings_Section, L"SaveSettings", Settings.SaveSettings);
|
||||
IniFileSetBool(Paths.IniFile, Constants.Settings_Section, L"SaveSettings", Settings.SaveSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6490,9 +6490,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
Flags.NoFileVariables = !Flags.NoFileVariables;
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
if (Flags.NoFileVariables != DefaultFlags.NoFileVariables) {
|
||||
IniFileSetInt(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"NoFileVariables", Flags.NoFileVariables);
|
||||
IniFileSetInt(Paths.IniFile, Constants.Settings2_Section, L"NoFileVariables", Flags.NoFileVariables);
|
||||
} else {
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"NoFileVariables", false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings2_Section, L"NoFileVariables", false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -6747,7 +6747,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
WCHAR tchDefWinPos[80];
|
||||
StringCchPrintf(tchDefWinPos, COUNTOF(tchDefWinPos), L"%i,%i,%i,%i,%i", wi.x, wi.y, wi.cx, wi.cy, wi.max);
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
IniFileSetString(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"DefaultWindowPosition", tchDefWinPos);
|
||||
IniFileSetString(Paths.IniFile, Constants.Settings2_Section, L"DefaultWindowPosition", tchDefWinPos);
|
||||
}
|
||||
g_DefWinInfo = wi; //GetWinInfoByFlag(-1); // use current win pos as new default
|
||||
}
|
||||
@ -6755,7 +6755,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case CMD_CLEARSAVEDWINPOS:
|
||||
g_DefWinInfo = GetFactoryDefaultWndPos(2);
|
||||
IniFileDelete(Path_Get(Paths.IniFile), Constants.Settings2_Section, L"DefaultWindowPosition", false);
|
||||
IniFileDelete(Paths.IniFile, Constants.Settings2_Section, L"DefaultWindowPosition", false);
|
||||
break;
|
||||
|
||||
case CMD_OPENINIFILE:
|
||||
|
||||
@ -895,19 +895,30 @@ bool PTHAPI Path_IsExistingDirectory(const HPATHL hpth)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2)
|
||||
int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir)
|
||||
{
|
||||
HSTRINGW hstr1 = ToHStrgW(hpth1);
|
||||
if (!hstr1 || !StrgGet(hstr1))
|
||||
if (Path_IsEmpty(hpth1)) {
|
||||
return -1;
|
||||
HSTRINGW hstr2 = ToHStrgW(hpth2);
|
||||
if (!hstr2 || !StrgGet(hstr2))
|
||||
return 1;
|
||||
}
|
||||
if (Path_IsEmpty(hpth2)) {
|
||||
return +1;
|
||||
}
|
||||
|
||||
size_t const max_len = min_s(StrgGetLength(hstr1), StrgGetLength(hstr2)) + 1;
|
||||
HPATHL hpth1_tmp = Path_Copy(hpth1);
|
||||
HPATHL hpth2_tmp = Path_Copy(hpth2);
|
||||
|
||||
//~return wcsncmp(StrgGet(hstr1), StrgGet(hstr2), max_len);
|
||||
return _wcsnicmp(StrgGet(hstr1), StrgGet(hstr2), max_len);
|
||||
Path_NormalizeEx(hpth1_tmp, hpth_wrkdir, true, false);
|
||||
Path_NormalizeEx(hpth2_tmp, hpth_wrkdir, true, false);
|
||||
|
||||
size_t const max_len = min_s(Path_GetLength(hpth1_tmp), Path_GetLength(hpth2_tmp)) + 1;
|
||||
|
||||
//~int const cmp = wcsncmp(Path_Get(hpth1_tmp), Path_Get(hpth2_tmp), max_len);
|
||||
int const cmp = _wcsnicmp(Path_Get(hpth1_tmp), Path_Get(hpth2_tmp), max_len);
|
||||
|
||||
Path_Release(hpth1_tmp);
|
||||
Path_Release(hpth2_tmp);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ inline bool PTHAPI Path_IsNotEmpty(const HPATHL hpth) { return !Path_IsEmpty
|
||||
bool PTHAPI Path_IsValidUNC(const HPATHL hpth);
|
||||
bool PTHAPI Path_IsExistingDirectory(const HPATHL hpth);
|
||||
|
||||
int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2);
|
||||
int PTHAPI Path_StrgComparePath(const HPATHL hpth1, const HPATHL hpth2, const HPATHL hpth_wrkdir);
|
||||
bool PTHAPI Path_RemoveBackslash(HPATHL hpth_in_out);
|
||||
bool PTHAPI Path_RemoveFileSpec(HPATHL hpth_in_out);
|
||||
bool PTHAPI Path_RenameExtension(HPATHL hpth, LPCWSTR ext);
|
||||
|
||||
56
src/Styles.c
56
src/Styles.c
@ -535,11 +535,11 @@ bool Style_DynamicThemesMenuCmd(int cmd)
|
||||
if (!Flags.bSettingsFileSoftLocked) {
|
||||
Globals.bCanSaveIniFile = CreateIniFile(Paths.IniFile, NULL);
|
||||
if (Globals.bCanSaveIniFile) {
|
||||
Style_ExportToFile(Path_Get(Paths.IniFile), false);
|
||||
Style_ExportToFile(Paths.IniFile, false);
|
||||
}
|
||||
}
|
||||
} else if (Path_IsExistingFile(Theme_Files[Globals.uCurrentThemeIndex].hStyleFilePath)) {
|
||||
Style_ExportToFile(Path_Get(Theme_Files[Globals.uCurrentThemeIndex].hStyleFilePath), false);
|
||||
Style_ExportToFile(Theme_Files[Globals.uCurrentThemeIndex].hStyleFilePath, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,7 +701,7 @@ bool Style_Import(HWND hwnd)
|
||||
|
||||
if (GetOpenFileNameW(&ofn)) {
|
||||
Path_Sanitize(hfile_pth);
|
||||
result = Style_ImportFromFile(file_buf);
|
||||
result = Style_ImportFromFile(hfile_pth);
|
||||
}
|
||||
|
||||
StrgDestroy(hflt_str);
|
||||
@ -770,7 +770,7 @@ void Style_Prerequisites() {
|
||||
_FillThemesMenuTable();
|
||||
_LoadLexerFileExtensions();
|
||||
|
||||
///~ Style_ImportFromFile(Path_Get(Paths.IniFile)); ~ done later
|
||||
///~ Style_ImportFromFile(Paths.IniFile); ~ done later
|
||||
}
|
||||
|
||||
|
||||
@ -937,21 +937,13 @@ static void _ReadFromIniCache() {
|
||||
//
|
||||
// Style_ImportFromFile()
|
||||
//
|
||||
bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
bool Style_ImportFromFile(const HPATHL hpath)
|
||||
{
|
||||
bool const bHaveFileResource = StrIsNotEmpty(szFile);
|
||||
bool bIsStdIniFile = false;
|
||||
if (bHaveFileResource) {
|
||||
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 const bHaveFileResource = Path_IsNotEmpty(hpath);
|
||||
bool const bIsStdIniFile = bHaveFileResource ? (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory) == 0) : false;
|
||||
|
||||
bool bOpendByMe = false;
|
||||
bool const result = bIsStdIniFile ? OpenSettingsFile(&bOpendByMe) : (bHaveFileResource ? LoadIniFileCache(szFile) : true);
|
||||
bool const result = bIsStdIniFile ? OpenSettingsFile(&bOpendByMe) : (bHaveFileResource ? LoadIniFileCache(hpath) : true);
|
||||
if (result) {
|
||||
_ReadFromIniCache();
|
||||
CloseSettingsFile(false, bOpendByMe);
|
||||
@ -971,7 +963,7 @@ bool Style_ImportTheme(const int iThemeIdx) {
|
||||
return Style_ImportFromFile(NULL);
|
||||
default:
|
||||
if ((iThemeIdx >= 0) && (iThemeIdx < (int)ThemeItems_CountOf()) && Path_IsExistingFile(Theme_Files[iThemeIdx].hStyleFilePath)) {
|
||||
return Style_ImportFromFile(Path_Get(Theme_Files[iThemeIdx].hStyleFilePath));
|
||||
return Style_ImportFromFile(Theme_Files[iThemeIdx].hStyleFilePath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -986,7 +978,7 @@ bool Style_ImportTheme(const int iThemeIdx) {
|
||||
void Style_SaveSettings(bool bForceSaveSettings)
|
||||
{
|
||||
if (Settings.SaveSettings || bForceSaveSettings) {
|
||||
Style_ExportToFile(Path_Get(Theme_Files[Globals.uCurrentThemeIndex].hStyleFilePath), false);
|
||||
Style_ExportToFile(Theme_Files[Globals.uCurrentThemeIndex].hStyleFilePath, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,7 +1013,7 @@ bool Style_Export(HWND hwnd)
|
||||
|
||||
if (GetSaveFileNameW(&ofn)) {
|
||||
Path_Sanitize(hfile_pth);
|
||||
result = Style_ExportToFile(file_buf, true);
|
||||
result = Style_ExportToFile(hfile_pth, true);
|
||||
if (!result) {
|
||||
InfoBoxLng(MB_ICONERROR, NULL, IDS_MUI_EXPORT_FAIL, Path_FindFileName(hfile_pth));
|
||||
}
|
||||
@ -1168,22 +1160,20 @@ bool Style_ToIniSection(bool bForceAll)
|
||||
//
|
||||
// Style_ExportToFile()
|
||||
//
|
||||
bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
|
||||
bool Style_ExportToFile(const HPATHL hpath, bool bForceAll)
|
||||
{
|
||||
if (StrIsEmpty(szFile)) {
|
||||
if (Path_IsEmpty(hpath)) {
|
||||
if (Globals.uCurrentThemeIndex != 0) {
|
||||
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SETTINGSNOTSAVED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HPATHL hpth = Path_Allocate(szFile);
|
||||
Path_NormalizeEx(hpth, Paths.ModuleDirectory, true, false);
|
||||
|
||||
bool ok = false;
|
||||
bool const bIsStdIniFile = (Path_StrgComparePath(hpath, Paths.IniFile, Paths.ModuleDirectory) == 0);
|
||||
|
||||
// special handling of standard .ini-file
|
||||
if (StringCchCompareXI(Path_Get(hpth), Path_Get(Paths.IniFile)) == 0) {
|
||||
bool ok = false;
|
||||
if (bIsStdIniFile) {
|
||||
bool bOpendByMe = false;
|
||||
if (OpenSettingsFile(&bOpendByMe)) {
|
||||
Style_ToIniSection(bForceAll);
|
||||
@ -1191,9 +1181,11 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
|
||||
ok = CloseSettingsFile(true, bOpendByMe);
|
||||
}
|
||||
} else {
|
||||
if (Path_IsNotEmpty(hpth)) {
|
||||
if (!Path_IsExistingFile(hpth)) {
|
||||
HANDLE hFile = CreateFile(Path_Get(hpth),
|
||||
HPATHL hpth_tmp = Path_Copy(hpath);
|
||||
Path_NormalizeEx(hpth_tmp, Paths.WorkingDirectory, true, false);
|
||||
if (Path_IsNotEmpty(hpth_tmp)) {
|
||||
if (!Path_IsExistingFile(hpth_tmp)) {
|
||||
HANDLE hFile = CreateFile(Path_Get(hpth_tmp),
|
||||
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (IS_VALID_HANDLE(hFile)) {
|
||||
@ -1201,15 +1193,15 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
|
||||
}
|
||||
}
|
||||
ResetIniFileCache();
|
||||
if (LoadIniFileCache(Path_Get(hpth))) {
|
||||
if (LoadIniFileCache(hpth_tmp)) {
|
||||
Style_ToIniSection(bForceAll);
|
||||
Style_FileExtToIniSection(bForceAll);
|
||||
ok = SaveIniFileCache(Path_Get(hpth));
|
||||
ok = SaveIniFileCache(hpth_tmp);
|
||||
ResetIniFileCache();
|
||||
}
|
||||
}
|
||||
Path_Release(hpth_tmp);
|
||||
}
|
||||
Path_Release(hpth);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ int Style_NumOfLexers(); // Number of Lexers in pLexArray
|
||||
void Style_Prerequisites();
|
||||
bool Style_Import(HWND hwnd);
|
||||
bool Style_ImportTheme(const int iThemeIdx); // -1 => Factory Reset
|
||||
bool Style_ImportFromFile(const WCHAR* szFile);
|
||||
bool Style_ImportFromFile(const HPATHL hpath);
|
||||
void Style_SaveSettings(bool bForceSaveSettings);
|
||||
bool Style_Export(HWND hwnd);
|
||||
void Style_FileExtToIniSection(bool bForceAll);
|
||||
void Style_CanonicalSectionToIniCache();
|
||||
bool Style_ToIniSection(bool bForceAll);
|
||||
bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll);
|
||||
bool Style_ExportToFile(const HPATHL hpath, bool bForceAll);
|
||||
|
||||
unsigned ThemeItems_CountOf();
|
||||
void ThemesItems_Init();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user