Skip to content

Commit

Permalink
Only load settings file from program directory, Application Data or M…
Browse files Browse the repository at this point in the history
…y Documents folder.
  • Loading branch information
zufuliu committed Jan 14, 2019
1 parent 8b3ef08 commit 63f3bad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions metapath/src/metapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -2886,19 +2886,15 @@ int CheckIniFile(LPWSTR lpszFile, LPCWSTR lpszModule) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
// %appdata%
if (S_OK == SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tchBuild)) {
// Application Data or My Documents
if (S_OK == SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tchBuild)
|| S_OK == SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, tchBuild)) {
PathAppend(tchBuild, tchFileExpanded);
if (PathFileExists(tchBuild)) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
}
// general
if (SearchPath(NULL, tchFileExpanded, NULL, COUNTOF(tchBuild), tchBuild, NULL)) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
} else if (PathFileExists(tchFileExpanded)) {
lstrcpy(lpszFile, tchFileExpanded);
return 1;
Expand Down
10 changes: 3 additions & 7 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -6380,19 +6380,15 @@ int CheckIniFile(LPWSTR lpszFile, LPCWSTR lpszModule) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
// %appdata%
if (S_OK == SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tchBuild)) {
// Application Data or My Documents
if (S_OK == SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tchBuild)
|| S_OK == SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, tchBuild)) {
PathAppend(tchBuild, tchFileExpanded);
if (PathFileExists(tchBuild)) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
}
// general
if (SearchPath(NULL, tchFileExpanded, NULL, COUNTOF(tchBuild), tchBuild, NULL)) {
lstrcpy(lpszFile, tchBuild);
return 1;
}
} else if (PathFileExists(tchFileExpanded)) {
lstrcpy(lpszFile, tchFileExpanded);
return 1;
Expand Down

0 comments on commit 63f3bad

Please sign in to comment.