Don Ho 2024-07-04 18:37:00 +02:00
parent ac67f15c2b
commit 0858dfa4af
19 changed files with 196 additions and 172 deletions

View File

@ -54,7 +54,7 @@ wstring commafyInt(size_t n)
std::string getFileContent(const wchar_t *file2read) std::string getFileContent(const wchar_t *file2read)
{ {
if (!::PathFileExists(file2read)) if (!doesFileExist(file2read))
return ""; return "";
const size_t blockSize = 1024; const size_t blockSize = 1024;
@ -1217,7 +1217,7 @@ bool isAssoCommandExisting(LPCTSTR FullPathName)
{ {
bool isAssoCommandExisting = false; bool isAssoCommandExisting = false;
bool isFileExisting = PathFileExists(FullPathName) != FALSE; bool isFileExisting = doesFileExist(FullPathName);
if (isFileExisting) if (isFileExisting)
{ {
@ -1462,10 +1462,11 @@ HFONT createFont(const wchar_t* fontName, int fontSize, bool isBold, HWND hDestP
bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath) bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath)
{ {
if (!PathFileExists(fileFullPath)) DWORD dwFileAttribs = ::GetFileAttributes(fileFullPath);
if (dwFileAttribs == INVALID_FILE_ATTRIBUTES || (dwFileAttribs & FILE_ATTRIBUTE_DIRECTORY))
return false; return false;
DWORD dwFileAttribs = ::GetFileAttributes(fileFullPath);
dwFileAttribs &= ~FILE_ATTRIBUTE_READONLY; dwFileAttribs &= ~FILE_ATTRIBUTE_READONLY;
return (::SetFileAttributes(fileFullPath, dwFileAttribs) != FALSE); return (::SetFileAttributes(fileFullPath, dwFileAttribs) != FALSE);
} }
@ -1637,8 +1638,9 @@ Version::Version(const wstring& versionStr)
void Version::setVersionFrom(const wstring& filePath) void Version::setVersionFrom(const wstring& filePath)
{ {
if (!filePath.empty() && ::PathFileExists(filePath.c_str())) if (filePath.empty() || !doesFileExist(filePath.c_str()))
{ return;
DWORD uselessArg = 0; // this variable is for passing the ignored argument to the functions DWORD uselessArg = 0; // this variable is for passing the ignored argument to the functions
DWORD bufferSize = ::GetFileVersionInfoSize(filePath.c_str(), &uselessArg); DWORD bufferSize = ::GetFileVersionInfoSize(filePath.c_str(), &uselessArg);
@ -1659,7 +1661,6 @@ void Version::setVersionFrom(const wstring& filePath)
_build = lpFileInfo->dwFileVersionLS & 0x0000FFFF; _build = lpFileInfo->dwFileVersionLS & 0x0000FFFF;
} }
delete[] buffer; delete[] buffer;
}
} }
wstring Version::toString() wstring Version::toString()
@ -1764,3 +1765,21 @@ bool Version::isCompatibleTo(const Version& from, const Version& to) const
return false; return false;
} }
bool doesFileExist(const wchar_t* filePath)
{
DWORD dwAttrib = ::GetFileAttributesW(filePath);
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
bool doesDirectoryExist(const wchar_t* dirPath)
{
DWORD dwAttrib = ::GetFileAttributesW(dirPath);
return (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}
bool doesPathExist(const wchar_t* path)
{
DWORD dwAttrib = ::GetFileAttributesW(path);
return (dwAttrib != INVALID_FILE_ATTRIBUTES);
}

View File

@ -13,6 +13,7 @@
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once #pragma once
#include <vector> #include <vector>
#include <string> #include <string>
@ -24,6 +25,8 @@
#include <algorithm> #include <algorithm>
#include <tchar.h> #include <tchar.h>
#pragma deprecated(PathFileExists) // Use doesFileExist, doesDirectoryExist or doesPathExist (for file or directory) instead.
const bool dirUp = true; const bool dirUp = true;
const bool dirDown = false; const bool dirDown = false;
@ -278,3 +281,7 @@ private:
unsigned long _patch = 0; unsigned long _patch = 0;
unsigned long _build = 0; unsigned long _build = 0;
}; };
bool doesFileExist(const wchar_t* filePath);
bool doesDirectoryExist(const wchar_t* dirPath);
bool doesPathExist(const wchar_t* path);

View File

@ -32,8 +32,8 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
WIN32_FILE_ATTRIBUTE_DATA attributes_original{}; WIN32_FILE_ATTRIBUTE_DATA attributes_original{};
DWORD dispParam = CREATE_ALWAYS; DWORD dispParam = CREATE_ALWAYS;
BOOL doesFileExist = ::PathFileExistsW(fname); bool fileExists = doesFileExist(fname);
if (doesFileExist) if (fileExists)
{ {
// Store the file creation date & attributes for a possible use later... // Store the file creation date & attributes for a possible use later...
::GetFileAttributesExW(fname, GetFileExInfoStandard, &attributes_original); ::GetFileAttributesExW(fname, GetFileExInfoStandard, &attributes_original);
@ -59,7 +59,7 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
_hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL); _hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL);
} }
if (doesFileExist && (dispParam == CREATE_ALWAYS) && (_hFile != INVALID_HANDLE_VALUE)) if (fileExists && (dispParam == CREATE_ALWAYS) && (_hFile != INVALID_HANDLE_VALUE))
{ {
// restore back the original creation date & attributes // restore back the original creation date & attributes
::SetFileTime(_hFile, &(attributes_original.ftCreationTime), NULL, NULL); ::SetFileTime(_hFile, &(attributes_original.ftCreationTime), NULL, NULL);

View File

@ -239,16 +239,16 @@ int PluginsManager::loadPluginFromPath(const wchar_t *pluginFilePath)
PathRemoveExtension(xmlPath); PathRemoveExtension(xmlPath);
PathAddExtension(xmlPath, L".xml"); PathAddExtension(xmlPath, L".xml");
if (!PathFileExists(xmlPath)) if (!doesFileExist(xmlPath))
{ {
lstrcpyn(xmlPath, L"\0", MAX_PATH ); lstrcpyn(xmlPath, L"\0", MAX_PATH );
wcscpy_s(xmlPath, nppParams.getAppDataNppDir() ); wcscpy_s(xmlPath, nppParams.getAppDataNppDir());
PathAppend(xmlPath, L"plugins\\Config"); PathAppend(xmlPath, L"plugins\\Config");
PathAppend(xmlPath, pi->_moduleName.c_str()); PathAppend(xmlPath, pi->_moduleName.c_str());
PathRemoveExtension( xmlPath ); PathRemoveExtension(xmlPath);
PathAddExtension( xmlPath, L".xml" ); PathAddExtension(xmlPath, L".xml");
if (! PathFileExists( xmlPath ) ) if (!doesFileExist(xmlPath))
{ {
throw wstring(wstring(xmlPath) + L" is missing."); throw wstring(wstring(xmlPath) + L" is missing.");
} }

View File

@ -598,7 +598,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
for (int i = 0; i < nbLRFile; ++i) for (int i = 0; i < nbLRFile; ++i)
{ {
wstring * stdStr = nppParam.getLRFile(i); wstring * stdStr = nppParam.getLRFile(i);
if (!nppGUI._checkHistoryFiles || PathFileExists(stdStr->c_str())) if (!nppGUI._checkHistoryFiles || doesFileExist(stdStr->c_str()))
{ {
_lastRecentFileList.add(stdStr->c_str()); _lastRecentFileList.add(stdStr->c_str());
} }
@ -1876,7 +1876,7 @@ void Notepad_plus::getMatchedFileNames(const wchar_t *dir, size_t level, const v
bool Notepad_plus::createFilelistForFiles(vector<wstring> & fileNames) bool Notepad_plus::createFilelistForFiles(vector<wstring> & fileNames)
{ {
const wchar_t *dir2Search = _findReplaceDlg.getDir2Search(); const wchar_t *dir2Search = _findReplaceDlg.getDir2Search();
if (!dir2Search[0] || !::PathFileExists(dir2Search)) if (!dir2Search[0] || !doesDirectoryExist(dir2Search))
{ {
return false; return false;
} }
@ -2579,7 +2579,7 @@ void Notepad_plus::checkDocState()
bool isCurrentDirty = curBuf->isDirty(); bool isCurrentDirty = curBuf->isDirty();
bool isSeveralDirty = isCurrentDirty; bool isSeveralDirty = isCurrentDirty;
bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE; bool isFileExisting = doesFileExist(curBuf->getFullPathName());
if (!isCurrentDirty) if (!isCurrentDirty)
{ {
for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i) for (size_t i = 0; i < MainFileManager.getNbBuffers(); ++i)
@ -6298,7 +6298,7 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session, bool includUntitledD
continue; continue;
if (!includUntitledDoc) if (!includUntitledDoc)
if (!PathFileExists(buf->getFullPathName())) if (!doesFileExist(buf->getFullPathName()))
continue; continue;
@ -6947,7 +6947,7 @@ vector<wstring> Notepad_plus::addNppComponents(const wchar_t *destDir, const wch
wstring destDirName = (NppParameters::getInstance()).getNppPath(); wstring destDirName = (NppParameters::getInstance()).getNppPath();
pathAppend(destDirName, destDir); pathAppend(destDirName, destDir);
if (!::PathFileExists(destDirName.c_str())) if (!doesDirectoryExist(destDirName.c_str()))
{ {
::CreateDirectory(destDirName.c_str(), NULL); ::CreateDirectory(destDirName.c_str(), NULL);
} }
@ -6957,7 +6957,7 @@ vector<wstring> Notepad_plus::addNppComponents(const wchar_t *destDir, const wch
size_t sz = fns.size(); size_t sz = fns.size();
for (size_t i = 0 ; i < sz ; ++i) for (size_t i = 0 ; i < sz ; ++i)
{ {
if (::PathFileExists(fns.at(i).c_str())) if (doesFileExist(fns.at(i).c_str()))
{ {
// copy to plugins directory // copy to plugins directory
wstring destName = destDirName; wstring destName = destDirName;
@ -6983,7 +6983,7 @@ vector<wstring> Notepad_plus::addNppPlugins(const wchar_t *extFilterName, const
// Get plugins dir // Get plugins dir
wstring destDirName = (NppParameters::getInstance()).getPluginRootDir(); wstring destDirName = (NppParameters::getInstance()).getPluginRootDir();
if (!::PathFileExists(destDirName.c_str())) if (!doesDirectoryExist(destDirName.c_str()))
{ {
::CreateDirectory(destDirName.c_str(), NULL); ::CreateDirectory(destDirName.c_str(), NULL);
} }
@ -6991,7 +6991,7 @@ vector<wstring> Notepad_plus::addNppPlugins(const wchar_t *extFilterName, const
size_t sz = fns.size(); size_t sz = fns.size();
for (size_t i = 0 ; i < sz ; ++i) for (size_t i = 0 ; i < sz ; ++i)
{ {
if (::PathFileExists(fns.at(i).c_str())) if (doesFileExist(fns.at(i).c_str()))
{ {
// copy to plugins directory // copy to plugins directory
wstring destName = destDirName; wstring destName = destDirName;
@ -7003,7 +7003,7 @@ vector<wstring> Notepad_plus::addNppPlugins(const wchar_t *extFilterName, const
wstring name = nameExt.substr(0, pos); wstring name = nameExt.substr(0, pos);
pathAppend(destName, name); pathAppend(destName, name);
if (!::PathFileExists(destName.c_str())) if (!doesDirectoryExist(destName.c_str()))
{ {
::CreateDirectory(destName.c_str(), NULL); ::CreateDirectory(destName.c_str(), NULL);
} }
@ -8518,7 +8518,7 @@ void Notepad_plus::refreshDarkMode(bool resetStyle)
pathAppend(themePath, xmlFileName); pathAppend(themePath, xmlFileName);
} }
if (::PathFileExists(themePath.c_str()) == FALSE || themePath.empty()) if (themePath.empty() || !doesFileExist(themePath.c_str()))
{ {
themePath = themeSwitcher.getThemeDirPath(); themePath = themeSwitcher.getThemeDirPath();
pathAppend(themePath, xmlFileName); pathAppend(themePath, xmlFileName);
@ -8535,7 +8535,7 @@ void Notepad_plus::refreshDarkMode(bool resetStyle)
themeName = themeSwitcher.getDefaultThemeLabel(); themeName = themeSwitcher.getDefaultThemeLabel();
} }
if (::PathFileExists(themePath.c_str()) == TRUE) if (doesFileExist(themePath.c_str()))
{ {
nppParams.getNppGUI()._themeName = themePath; nppParams.getNppGUI()._themeName = themePath;

View File

@ -246,7 +246,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdL
{ {
wstring appDataThemePath = appDataThemeDir; wstring appDataThemePath = appDataThemeDir;
if (!::PathFileExists(appDataThemePath.c_str())) if (!doesDirectoryExist(appDataThemePath.c_str()))
{ {
::CreateDirectory(appDataThemePath.c_str(), NULL); ::CreateDirectory(appDataThemePath.c_str(), NULL);
} }
@ -271,7 +271,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdL
pathAppend(themePath, xmlFileName); pathAppend(themePath, xmlFileName);
} }
if (::PathFileExists(themePath.c_str()) == FALSE || themePath.empty()) if (themePath.empty() || !doesFileExist(themePath.c_str()))
{ {
themePath = themeSwitcher.getThemeDirPath(); themePath = themeSwitcher.getThemeDirPath();
pathAppend(themePath, xmlFileName); pathAppend(themePath, xmlFileName);
@ -283,7 +283,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdL
themePath = themeInfo.second; themePath = themeInfo.second;
} }
if (::PathFileExists(themePath.c_str()) == TRUE) if (doesFileExist(themePath.c_str()))
{ {
nppGUI._themeName.assign(themePath); nppGUI._themeName.assign(themePath);
nppParams.reloadStylers(themePath.c_str()); nppParams.reloadStylers(themePath.c_str());
@ -362,7 +362,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdL
} }
else if (cmdLineParams->_quoteType == 2) // content drom file else if (cmdLineParams->_quoteType == 2) // content drom file
{ {
if (::PathFileExists(cmdLineParams->_easterEggName.c_str())) if (doesFileExist(cmdLineParams->_easterEggName.c_str()))
{ {
std::string content = getFileContent(cmdLineParams->_easterEggName.c_str()); std::string content = getFileContent(cmdLineParams->_easterEggName.c_str());
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();

View File

@ -2168,11 +2168,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// Then ReadDirectoryChanges does not detect the change. // Then ReadDirectoryChanges does not detect the change.
// Fortunately, notification is sent if right click or double click happens on that file // Fortunately, notification is sent if right click or double click happens on that file
// Let's leverage this as workaround to enhance npp file monitoring functionality. // Let's leverage this as workaround to enhance npp file monitoring functionality.
// So calling "PathFileExists" is a workaround here. // So calling "doesFileExist" is a workaround here.
Buffer* currBuf = getCurrentBuffer(); Buffer* currBuf = getCurrentBuffer();
if (currBuf && currBuf->isMonitoringOn()) if (currBuf && currBuf->isMonitoringOn())
::PathFileExists(currBuf->getFullPathName()); doesFileExist(currBuf->getFullPathName());
const NppGUI & nppgui = nppParam.getNppGUI(); const NppGUI & nppgui = nppParam.getNppGUI();
if (nppgui._fileAutoDetection != cdDisabled) if (nppgui._fileAutoDetection != cdDisabled)
@ -2762,7 +2762,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// saving session.xml into loaded session if a saved session is loaded and saveLoadedSessionOnExit option is enabled // saving session.xml into loaded session if a saved session is loaded and saveLoadedSessionOnExit option is enabled
// //
wstring loadedSessionFilePath = nppParam.getLoadedSessionFilePath(); wstring loadedSessionFilePath = nppParam.getLoadedSessionFilePath();
if (!loadedSessionFilePath.empty() && PathFileExists(loadedSessionFilePath.c_str())) if (!loadedSessionFilePath.empty() && doesFileExist(loadedSessionFilePath.c_str()))
nppParam.writeSession(currentSession, loadedSessionFilePath.c_str()); nppParam.writeSession(currentSession, loadedSessionFilePath.c_str());
} }

View File

@ -586,8 +586,8 @@ void Notepad_plus::command(int id)
::SendMessage(hwnd, NPPM_GETNPPFULLFILEPATH, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(cmd2Exec)); ::SendMessage(hwnd, NPPM_GETNPPFULLFILEPATH, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(cmd2Exec));
} }
// Full file path // Full file path: could be a folder or a file
if (::PathFileExists(curentWord)) if (doesPathExist(curentWord))
{ {
wstring fullFilePath = id == IDM_EDIT_OPENINFOLDER ? L"/select," : L""; wstring fullFilePath = id == IDM_EDIT_OPENINFOLDER ? L"/select," : L"";
fullFilePath += L"\""; fullFilePath += L"\"";
@ -598,7 +598,7 @@ void Notepad_plus::command(int id)
(id == IDM_EDIT_OPENASFILE && !::PathIsDirectory(curentWord))) (id == IDM_EDIT_OPENASFILE && !::PathIsDirectory(curentWord)))
::ShellExecute(hwnd, L"open", cmd2Exec, fullFilePath.c_str(), L".", SW_SHOW); ::ShellExecute(hwnd, L"open", cmd2Exec, fullFilePath.c_str(), L".", SW_SHOW);
} }
else // Full file path - need concatenate with current full file path else // Relative file path - need concatenate with current full file path
{ {
wchar_t currentDir[CURRENTWORD_MAXLENGTH] = { '\0' }; wchar_t currentDir[CURRENTWORD_MAXLENGTH] = { '\0' };
::SendMessage(hwnd, NPPM_GETCURRENTDIRECTORY, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(currentDir)); ::SendMessage(hwnd, NPPM_GETCURRENTDIRECTORY, CURRENTWORD_MAXLENGTH, reinterpret_cast<LPARAM>(currentDir));
@ -610,7 +610,7 @@ void Notepad_plus::command(int id)
fullFilePath += curentWord; fullFilePath += curentWord;
if ((id == IDM_EDIT_OPENASFILE && if ((id == IDM_EDIT_OPENASFILE &&
(!::PathFileExists(fullFilePath.c_str() + 1) || ::PathIsDirectory(fullFilePath.c_str() + 1)))) (!doesFileExist(fullFilePath.c_str() + 1)))) // + 1 for skipping the 1st char '"'
{ {
_nativeLangSpeaker.messageBox("FilePathNotFoundWarning", _nativeLangSpeaker.messageBox("FilePathNotFoundWarning",
_pPublicInterface->getHSelf(), _pPublicInterface->getHSelf(),
@ -619,6 +619,8 @@ void Notepad_plus::command(int id)
MB_OK | MB_APPLMODAL); MB_OK | MB_APPLMODAL);
return; return;
} }
// else id == IDM_EDIT_OPENINFOLDER - do it anyway. (even the last part does not exist, it doesn't matter)
fullFilePath += L"\""; fullFilePath += L"\"";
::ShellExecute(hwnd, L"open", cmd2Exec, fullFilePath.c_str(), L".", SW_SHOW); ::ShellExecute(hwnd, L"open", cmd2Exec, fullFilePath.c_str(), L".", SW_SHOW);
} }
@ -2769,7 +2771,7 @@ void Notepad_plus::command(int id)
else else
{ {
const wchar_t *longFileName = curBuf->getFullPathName(); const wchar_t *longFileName = curBuf->getFullPathName();
if (::PathFileExists(longFileName)) if (doesFileExist(longFileName))
{ {
if (curBuf->isDirty()) if (curBuf->isDirty())
{ {
@ -3577,7 +3579,7 @@ void Notepad_plus::command(int id)
{ {
wstring noEasterEggsPath((NppParameters::getInstance()).getNppPath()); wstring noEasterEggsPath((NppParameters::getInstance()).getNppPath());
noEasterEggsPath.append(L"\\noEasterEggs.xml"); noEasterEggsPath.append(L"\\noEasterEggs.xml");
if (!::PathFileExists(noEasterEggsPath.c_str())) if (!doesFileExist(noEasterEggsPath.c_str()))
showAllQuotes(); showAllQuotes();
return; return;
} }
@ -3585,7 +3587,7 @@ void Notepad_plus::command(int id)
{ {
wstring noEasterEggsPath((NppParameters::getInstance()).getNppPath()); wstring noEasterEggsPath((NppParameters::getInstance()).getNppPath());
noEasterEggsPath.append(L"\\noEasterEggs.xml"); noEasterEggsPath.append(L"\\noEasterEggs.xml");
if (!::PathFileExists(noEasterEggsPath.c_str())) if (!doesFileExist(noEasterEggsPath.c_str()))
showQuoteFromIndex(iQuote); showQuoteFromIndex(iQuote);
return; return;
} }

View File

@ -255,8 +255,8 @@ BufferID Notepad_plus::doOpen(const wstring& fileName, bool isRecursive, bool is
} }
} }
bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); bool isSnapshotMode = backupFileName != NULL && doesFileExist(backupFileName);
if (isSnapshotMode && !PathFileExists(longFileName)) // UNTITLED if (isSnapshotMode && !doesFileExist(longFileName)) // UNTITLED
{ {
wcscpy_s(longFileName, targetFileName.c_str()); wcscpy_s(longFileName, targetFileName.c_str());
} }
@ -297,13 +297,13 @@ BufferID Notepad_plus::doOpen(const wstring& fileName, bool isRecursive, bool is
return foundBufID; return foundBufID;
} }
if (isFileSession(longFileName) && PathFileExists(longFileName)) if (isFileSession(longFileName) && doesFileExist(longFileName))
{ {
fileLoadSession(longFileName); fileLoadSession(longFileName);
return BUFFER_INVALID; return BUFFER_INVALID;
} }
if (isFileWorkspace(longFileName) && PathFileExists(longFileName)) if (isFileWorkspace(longFileName) && doesFileExist(longFileName))
{ {
nppParam.setWorkSpaceFilePath(0, longFileName); nppParam.setWorkSpaceFilePath(0, longFileName);
// This line switches to Project Panel 1 while starting up Npp // This line switches to Project Panel 1 while starting up Npp
@ -313,7 +313,7 @@ BufferID Notepad_plus::doOpen(const wstring& fileName, bool isRecursive, bool is
} }
bool isWow64Off = false; bool isWow64Off = false;
if (!PathFileExists(longFileName)) if (!doesFileExist(longFileName))
{ {
nppParam.safeWow64EnableWow64FsRedirection(FALSE); nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true; isWow64Off = true;
@ -327,13 +327,13 @@ BufferID Notepad_plus::doOpen(const wstring& fileName, bool isRecursive, bool is
if (!isSnapshotMode) // if not backup mode, or backupfile path is invalid if (!isSnapshotMode) // if not backup mode, or backupfile path is invalid
{ {
if (!PathFileExists(longFileName) && !globbing) if (!doesFileExist(longFileName) && !globbing)
{ {
wstring longFileDir(longFileName); wstring longFileDir(longFileName);
PathRemoveFileSpec(longFileDir); PathRemoveFileSpec(longFileDir);
bool isCreateFileSuccessful = false; bool isCreateFileSuccessful = false;
if (PathFileExists(longFileDir.c_str())) if (doesDirectoryExist(longFileDir.c_str()))
{ {
int res = _nativeLangSpeaker.messageBox("CreateNewFileOrNot", int res = _nativeLangSpeaker.messageBox("CreateNewFileOrNot",
_pPublicInterface->getHSelf(), _pPublicInterface->getHSelf(),
@ -414,7 +414,7 @@ BufferID Notepad_plus::doOpen(const wstring& fileName, bool isRecursive, bool is
if (buffer != BUFFER_INVALID) if (buffer != BUFFER_INVALID)
{ {
isSnapshotMode = (backupFileName != NULL && ::PathFileExists(backupFileName)); isSnapshotMode = (backupFileName != NULL && doesFileExist(backupFileName));
if (isSnapshotMode) if (isSnapshotMode)
{ {
// To notify plugins that a snapshot dirty file is loaded on startup // To notify plugins that a snapshot dirty file is loaded on startup
@ -792,13 +792,13 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
bool isWow64Off = false; bool isWow64Off = false;
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
const wchar_t *fn = buf->getFullPathName(); const wchar_t *fn = buf->getFullPathName();
if (!PathFileExists(fn)) if (!doesFileExist(fn))
{ {
nppParam.safeWow64EnableWow64FsRedirection(FALSE); nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true; isWow64Off = true;
} }
if (PathFileExists(buf->getFullPathName())) if (doesFileExist(buf->getFullPathName()))
fileFullPath = buf->getFullPathName(); fileFullPath = buf->getFullPathName();
// We enable Wow64 system, if it was disabled // We enable Wow64 system, if it was disabled
@ -1076,7 +1076,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
{ {
if (isSnapshotMode) if (isSnapshotMode)
{ {
if (buf->getBackupFileName() == L"" || !::PathFileExists(buf->getBackupFileName().c_str())) //backup file has been deleted from outside if (buf->getBackupFileName() == L"" || !doesFileExist(buf->getBackupFileName().c_str())) //backup file has been deleted from outside
{ {
// warning user and save it if user want it. // warning user and save it if user want it.
activateBuffer(id, MAIN_VIEW); activateBuffer(id, MAIN_VIEW);
@ -1160,7 +1160,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode)
{ {
if (isSnapshotMode) if (isSnapshotMode)
{ {
if (buf->getBackupFileName() == L"" || !::PathFileExists(buf->getBackupFileName().c_str())) //backup file has been deleted from outside if (buf->getBackupFileName() == L"" || !doesFileExist(buf->getBackupFileName().c_str())) //backup file has been deleted from outside
{ {
// warning user and save it if user want it. // warning user and save it if user want it.
activateBuffer(id, SUB_VIEW); activateBuffer(id, SUB_VIEW);
@ -1628,7 +1628,7 @@ bool Notepad_plus::fileSave(BufferID id)
fn_bak = fn_bak_expanded; fn_bak = fn_bak_expanded;
// Make sure the directory exists // Make sure the directory exists
if (!::PathFileExists(fn_bak.c_str())) if (!doesDirectoryExist(fn_bak.c_str()))
{ {
SHCreateDirectory(NULL, fn_bak.c_str()); SHCreateDirectory(NULL, fn_bak.c_str());
} }
@ -1895,7 +1895,7 @@ bool Notepad_plus::fileRename(BufferID id)
scnN.nmhdr.idFrom = (uptr_t)bufferID; scnN.nmhdr.idFrom = (uptr_t)bufferID;
bool success = false; bool success = false;
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE; bool isFileExisting = doesFileExist(buf->getFullPathName());
if (isFileExisting) if (isFileExisting)
{ {
CustomFileDialog fDlg(_pPublicInterface->getHSelf()); CustomFileDialog fDlg(_pPublicInterface->getHSelf());
@ -1998,7 +1998,7 @@ bool Notepad_plus::fileRenameUntitled(BufferID id, const wchar_t* tabNewName)
} }
Buffer* buf = MainFileManager.getBufferByID(bufferID); Buffer* buf = MainFileManager.getBufferByID(bufferID);
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE; bool isFileExisting = doesFileExist(buf->getFullPathName());
if (isFileExisting) return false; if (isFileExisting) return false;
// We are just going to rename the tab nothing else // We are just going to rename the tab nothing else
@ -2249,19 +2249,20 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
} }
bool isWow64Off = false; bool isWow64Off = false;
if (!PathFileExists(pFn)) if (!doesFileExist(pFn))
{ {
nppParam.safeWow64EnableWow64FsRedirection(FALSE); nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true; isWow64Off = true;
} }
if (PathFileExists(pFn))
if (doesFileExist(pFn))
{ {
if (isSnapshotMode && !session._mainViewFiles[i]._backupFilePath.empty()) if (isSnapshotMode && !session._mainViewFiles[i]._backupFilePath.empty())
lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding, session._mainViewFiles[i]._backupFilePath.c_str(), session._mainViewFiles[i]._originalFileLastModifTimestamp); lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding, session._mainViewFiles[i]._backupFilePath.c_str(), session._mainViewFiles[i]._originalFileLastModifTimestamp);
else else
lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding); lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding);
} }
else if (isSnapshotMode && PathFileExists(session._mainViewFiles[i]._backupFilePath.c_str())) else if (isSnapshotMode && doesFileExist(session._mainViewFiles[i]._backupFilePath.c_str()))
{ {
lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding, session._mainViewFiles[i]._backupFilePath.c_str(), session._mainViewFiles[i]._originalFileLastModifTimestamp); lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding, session._mainViewFiles[i]._backupFilePath.c_str(), session._mainViewFiles[i]._originalFileLastModifTimestamp);
} }
@ -2327,7 +2328,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
buf->setUserReadOnly(session._mainViewFiles[i]._isUserReadOnly); buf->setUserReadOnly(session._mainViewFiles[i]._isUserReadOnly);
if (isSnapshotMode && !session._mainViewFiles[i]._backupFilePath.empty() && PathFileExists(session._mainViewFiles[i]._backupFilePath.c_str())) if (isSnapshotMode && !session._mainViewFiles[i]._backupFilePath.empty() && doesFileExist(session._mainViewFiles[i]._backupFilePath.c_str()))
buf->setDirty(true); buf->setDirty(true);
buf->setRTL(session._mainViewFiles[i]._isRTL); buf->setRTL(session._mainViewFiles[i]._isRTL);
@ -2378,13 +2379,13 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
} }
bool isWow64Off = false; bool isWow64Off = false;
if (!PathFileExists(pFn)) if (!doesFileExist(pFn))
{ {
nppParam.safeWow64EnableWow64FsRedirection(FALSE); nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true; isWow64Off = true;
} }
if (PathFileExists(pFn)) if (doesFileExist(pFn))
{ {
//check if already open in main. If so, clone //check if already open in main. If so, clone
BufferID clonedBuf = _mainDocTab.findBufferByName(pFn); BufferID clonedBuf = _mainDocTab.findBufferByName(pFn);
@ -2401,7 +2402,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding); lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding);
} }
} }
else if (isSnapshotMode && PathFileExists(session._subViewFiles[k]._backupFilePath.c_str())) else if (isSnapshotMode && doesFileExist(session._subViewFiles[k]._backupFilePath.c_str()))
{ {
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding, session._subViewFiles[k]._backupFilePath.c_str(), session._subViewFiles[k]._originalFileLastModifTimestamp); lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding, session._subViewFiles[k]._backupFilePath.c_str(), session._subViewFiles[k]._originalFileLastModifTimestamp);
} }
@ -2458,7 +2459,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
buf->setEncoding(session._subViewFiles[k]._encoding); buf->setEncoding(session._subViewFiles[k]._encoding);
buf->setUserReadOnly(session._subViewFiles[k]._isUserReadOnly); buf->setUserReadOnly(session._subViewFiles[k]._isUserReadOnly);
if (isSnapshotMode && !session._subViewFiles[k]._backupFilePath.empty() && PathFileExists(session._subViewFiles[k]._backupFilePath.c_str())) if (isSnapshotMode && !session._subViewFiles[k]._backupFilePath.empty() && doesFileExist(session._subViewFiles[k]._backupFilePath.c_str()))
buf->setDirty(true); buf->setDirty(true);
buf->setRTL(session._subViewFiles[k]._isRTL); buf->setRTL(session._subViewFiles[k]._isRTL);
@ -2569,7 +2570,7 @@ bool Notepad_plus::fileLoadSession(const wchar_t *fn)
} }
else else
{ {
if (PathFileExists(fn)) if (doesFileExist(fn))
sessionFileName = fn; sessionFileName = fn;
} }
@ -2623,7 +2624,7 @@ const wchar_t * Notepad_plus::fileSaveSession(size_t nbFile, wchar_t ** fileName
{ {
for (size_t i = 0 ; i < nbFile ; ++i) for (size_t i = 0 ; i < nbFile ; ++i)
{ {
if (PathFileExists(fileNames[i])) if (doesFileExist(fileNames[i]))
currentSession._mainViewFiles.push_back(wstring(fileNames[i])); currentSession._mainViewFiles.push_back(wstring(fileNames[i]));
} }
} }

View File

@ -594,7 +594,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (isInaccessible) if (isInaccessible)
_tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, false); _tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, false);
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE; bool isFileExisting = doesFileExist(buf->getFullPathName());
_tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting); _tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting);
_tabPopupMenu.enableItem(IDM_FILE_RELOAD, isFileExisting); _tabPopupMenu.enableItem(IDM_FILE_RELOAD, isFileExisting);
_tabPopupMenu.enableItem(IDM_FILE_OPEN_FOLDER, isFileExisting); _tabPopupMenu.enableItem(IDM_FILE_OPEN_FOLDER, isFileExisting);

View File

@ -1008,7 +1008,7 @@ NppParameters::NppParameters()
std::wstring notepadStylePath(_nppPath); std::wstring notepadStylePath(_nppPath);
pathAppend(notepadStylePath, notepadStyleFile); pathAppend(notepadStylePath, notepadStyleFile);
_asNotepadStyle = (PathFileExists(notepadStylePath.c_str()) == TRUE); _asNotepadStyle = (doesFileExist(notepadStylePath.c_str()) == TRUE);
//Load initial accelerator key definitions //Load initial accelerator key definitions
initMenuKeys(); initMenuKeys();
@ -1079,11 +1079,11 @@ bool NppParameters::reloadLang()
std::wstring nativeLangPath(_localizationSwitcher._nativeLangPath); std::wstring nativeLangPath(_localizationSwitcher._nativeLangPath);
// if "nativeLang.xml" does not exist, use npp path // if "nativeLang.xml" does not exist, use npp path
if (!PathFileExists(nativeLangPath.c_str())) if (!doesFileExist(nativeLangPath.c_str()))
{ {
nativeLangPath = _nppPath; nativeLangPath = _nppPath;
pathAppend(nativeLangPath, std::wstring(L"nativeLang.xml")); pathAppend(nativeLangPath, std::wstring(L"nativeLang.xml"));
if (!PathFileExists(nativeLangPath.c_str())) if (!doesFileExist(nativeLangPath.c_str()))
return false; return false;
} }
@ -1142,7 +1142,7 @@ bool NppParameters::load()
pathAppend(localConfPath, localConfFile); pathAppend(localConfPath, localConfFile);
// Test if localConf.xml exist // Test if localConf.xml exist
_isLocal = (PathFileExists(localConfPath.c_str()) == TRUE); _isLocal = (doesFileExist(localConfPath.c_str()) == TRUE);
// Under vista and windows 7, the usage of doLocalConf.xml is not allowed // Under vista and windows 7, the usage of doLocalConf.xml is not allowed
// if Notepad++ is installed in "program files" directory, because of UAC // if Notepad++ is installed in "program files" directory, because of UAC
@ -1179,15 +1179,15 @@ bool NppParameters::load()
_userPath = getSpecialFolderLocation(CSIDL_APPDATA); _userPath = getSpecialFolderLocation(CSIDL_APPDATA);
pathAppend(_userPath, L"Notepad++"); pathAppend(_userPath, L"Notepad++");
if (!PathFileExists(_userPath.c_str())) if (!doesDirectoryExist(_userPath.c_str()))
::CreateDirectory(_userPath.c_str(), NULL); ::CreateDirectory(_userPath.c_str(), NULL);
_appdataNppDir = _userPluginConfDir = _userPath; _appdataNppDir = _userPluginConfDir = _userPath;
pathAppend(_userPluginConfDir, L"plugins"); pathAppend(_userPluginConfDir, L"plugins");
if (!PathFileExists(_userPluginConfDir.c_str())) if (!doesDirectoryExist(_userPluginConfDir.c_str()))
::CreateDirectory(_userPluginConfDir.c_str(), NULL); ::CreateDirectory(_userPluginConfDir.c_str(), NULL);
pathAppend(_userPluginConfDir, L"Config"); pathAppend(_userPluginConfDir, L"Config");
if (!PathFileExists(_userPluginConfDir.c_str())) if (!doesDirectoryExist(_userPluginConfDir.c_str()))
::CreateDirectory(_userPluginConfDir.c_str(), NULL); ::CreateDirectory(_userPluginConfDir.c_str(), NULL);
// For PluginAdmin to launch the wingup with UAC // For PluginAdmin to launch the wingup with UAC
@ -1197,9 +1197,9 @@ bool NppParameters::load()
_pluginConfDir = _pluginRootDir; // for plugin list home _pluginConfDir = _pluginRootDir; // for plugin list home
pathAppend(_pluginConfDir, L"Config"); pathAppend(_pluginConfDir, L"Config");
if (!PathFileExists(nppPluginRootParent.c_str())) if (!doesDirectoryExist(nppPluginRootParent.c_str()))
::CreateDirectory(nppPluginRootParent.c_str(), NULL); ::CreateDirectory(nppPluginRootParent.c_str(), NULL);
if (!PathFileExists(_pluginRootDir.c_str())) if (!doesDirectoryExist(_pluginRootDir.c_str()))
::CreateDirectory(_pluginRootDir.c_str(), NULL); ::CreateDirectory(_pluginRootDir.c_str(), NULL);
_sessionPath = _userPath; // Session stock the absolute file path, it should never be on cloud _sessionPath = _userPath; // Session stock the absolute file path, it should never be on cloud
@ -1211,7 +1211,7 @@ bool NppParameters::load()
// //
// the 2nd priority: cloud Choice Path // the 2nd priority: cloud Choice Path
// //
_isCloud = (::PathFileExists(cloudChoicePath.c_str()) == TRUE); _isCloud = doesFileExist(cloudChoicePath.c_str());
if (_isCloud) if (_isCloud)
{ {
// Read cloud choice // Read cloud choice
@ -1219,7 +1219,7 @@ bool NppParameters::load()
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
std::wstring cloudChoiceStrW = wmc.char2wchar(cloudChoiceStr.c_str(), SC_CP_UTF8); std::wstring cloudChoiceStrW = wmc.char2wchar(cloudChoiceStr.c_str(), SC_CP_UTF8);
if (!cloudChoiceStrW.empty() && ::PathFileExists(cloudChoiceStrW.c_str())) if (!cloudChoiceStrW.empty() && doesDirectoryExist(cloudChoiceStrW.c_str()))
{ {
_userPath = cloudChoiceStrW; _userPath = cloudChoiceStrW;
_nppGUI._cloudPath = cloudChoiceStrW; _nppGUI._cloudPath = cloudChoiceStrW;
@ -1259,7 +1259,7 @@ bool NppParameters::load()
pathAppend(langs_xml_path, L"langs.xml"); pathAppend(langs_xml_path, L"langs.xml");
BOOL doRecover = FALSE; BOOL doRecover = FALSE;
if (::PathFileExists(langs_xml_path.c_str())) if (doesFileExist(langs_xml_path.c_str()))
{ {
WIN32_FILE_ATTRIBUTE_DATA attributes{}; WIN32_FILE_ATTRIBUTE_DATA attributes{};
@ -1327,7 +1327,7 @@ bool NppParameters::load()
std::wstring srcConfigPath(_nppPath); std::wstring srcConfigPath(_nppPath);
pathAppend(srcConfigPath, L"config.model.xml"); pathAppend(srcConfigPath, L"config.model.xml");
if (!::PathFileExists(configPath.c_str())) if (!doesFileExist(configPath.c_str()))
::CopyFile(srcConfigPath.c_str(), configPath.c_str(), FALSE); ::CopyFile(srcConfigPath.c_str(), configPath.c_str(), FALSE);
_pXmlUserDoc = new TiXmlDocument(configPath); _pXmlUserDoc = new TiXmlDocument(configPath);
@ -1350,7 +1350,7 @@ bool NppParameters::load()
_stylerPath = _userPath; _stylerPath = _userPath;
pathAppend(_stylerPath, L"stylers.xml"); pathAppend(_stylerPath, L"stylers.xml");
if (!PathFileExists(_stylerPath.c_str())) if (!doesFileExist(_stylerPath.c_str()))
{ {
std::wstring srcStylersPath(_nppPath); std::wstring srcStylersPath(_nppPath);
pathAppend(srcStylersPath, L"stylers.model.xml"); pathAppend(srcStylersPath, L"stylers.model.xml");
@ -1358,7 +1358,7 @@ bool NppParameters::load()
::CopyFile(srcStylersPath.c_str(), _stylerPath.c_str(), TRUE); ::CopyFile(srcStylersPath.c_str(), _stylerPath.c_str(), TRUE);
} }
if (_nppGUI._themeName.empty() || (!PathFileExists(_nppGUI._themeName.c_str()))) if (_nppGUI._themeName.empty() || (!doesFileExist(_nppGUI._themeName.c_str())))
_nppGUI._themeName.assign(_stylerPath); _nppGUI._themeName.assign(_stylerPath);
_pXmlUserStylerDoc = new TiXmlDocument(_nppGUI._themeName.c_str()); _pXmlUserStylerDoc = new TiXmlDocument(_nppGUI._themeName.c_str());
@ -1454,7 +1454,7 @@ bool NppParameters::load()
} }
else // use %appdata% location, or (if absence then) npp installed location else // use %appdata% location, or (if absence then) npp installed location
{ {
if (!PathFileExists(nativeLangPath.c_str())) if (!doesFileExist(nativeLangPath.c_str()))
{ {
nativeLangPath = _nppPath; nativeLangPath = _nppPath;
pathAppend(nativeLangPath, L"nativeLang.xml"); pathAppend(nativeLangPath, L"nativeLang.xml");
@ -1495,7 +1495,7 @@ bool NppParameters::load()
pathAppend(_shortcutsPath, SHORTCUTSXML_FILENAME); pathAppend(_shortcutsPath, SHORTCUTSXML_FILENAME);
pathAppend(v852NoNeedShortcutsBackup, NONEEDSHORTCUTSXMLBACKUP_FILENAME); pathAppend(v852NoNeedShortcutsBackup, NONEEDSHORTCUTSXMLBACKUP_FILENAME);
if (!PathFileExists(_shortcutsPath.c_str())) if (!doesFileExist(_shortcutsPath.c_str()))
{ {
std::wstring srcShortcutsPath(_nppPath); std::wstring srcShortcutsPath(_nppPath);
pathAppend(srcShortcutsPath, SHORTCUTSXML_FILENAME); pathAppend(srcShortcutsPath, SHORTCUTSXML_FILENAME);
@ -1533,7 +1533,7 @@ bool NppParameters::load()
_contextMenuPath = _userPath; _contextMenuPath = _userPath;
pathAppend(_contextMenuPath, L"contextMenu.xml"); pathAppend(_contextMenuPath, L"contextMenu.xml");
if (!PathFileExists(_contextMenuPath.c_str())) if (!doesFileExist(_contextMenuPath.c_str()))
{ {
std::wstring srcContextMenuPath(_nppPath); std::wstring srcContextMenuPath(_nppPath);
pathAppend(srcContextMenuPath, L"contextMenu.xml"); pathAppend(srcContextMenuPath, L"contextMenu.xml");
@ -1586,10 +1586,10 @@ bool NppParameters::load()
{ {
wstring sessionInCaseOfCorruption_bak = _sessionPath; wstring sessionInCaseOfCorruption_bak = _sessionPath;
sessionInCaseOfCorruption_bak += SESSION_BACKUP_EXT; sessionInCaseOfCorruption_bak += SESSION_BACKUP_EXT;
if (::PathFileExists(sessionInCaseOfCorruption_bak.c_str())) if (doesFileExist(sessionInCaseOfCorruption_bak.c_str()))
{ {
BOOL bFileSwapOk = false; BOOL bFileSwapOk = false;
if (::PathFileExists(_sessionPath.c_str())) if (doesFileExist(_sessionPath.c_str()))
{ {
// an invalid session.xml file exists // an invalid session.xml file exists
bFileSwapOk = ::ReplaceFile(_sessionPath.c_str(), sessionInCaseOfCorruption_bak.c_str(), nullptr, bFileSwapOk = ::ReplaceFile(_sessionPath.c_str(), sessionInCaseOfCorruption_bak.c_str(), nullptr,
@ -1637,7 +1637,7 @@ bool NppParameters::load()
std::wstring enableSelectFgColorPath = _userPath; std::wstring enableSelectFgColorPath = _userPath;
pathAppend(enableSelectFgColorPath, L"enableSelectFgColor.xml"); pathAppend(enableSelectFgColorPath, L"enableSelectFgColor.xml");
if (PathFileExists(enableSelectFgColorPath.c_str())) if (doesFileExist(enableSelectFgColorPath.c_str()))
{ {
_isSelectFgColorEnabled = true; _isSelectFgColorEnabled = true;
} }
@ -1653,12 +1653,12 @@ bool NppParameters::load()
issueFileName = nppLogNetworkDriveIssue; issueFileName = nppLogNetworkDriveIssue;
issueFileName += L".xml"; issueFileName += L".xml";
pathAppend(filePath, issueFileName); pathAppend(filePath, issueFileName);
_doNppLogNetworkDriveIssue = (PathFileExists(filePath.c_str()) == TRUE); _doNppLogNetworkDriveIssue = doesFileExist(filePath.c_str());
if (!_doNppLogNetworkDriveIssue) if (!_doNppLogNetworkDriveIssue)
{ {
filePath2 = _userPath; filePath2 = _userPath;
pathAppend(filePath2, issueFileName); pathAppend(filePath2, issueFileName);
_doNppLogNetworkDriveIssue = (PathFileExists(filePath2.c_str()) == TRUE); _doNppLogNetworkDriveIssue = doesFileExist(filePath2.c_str());
} }
//-------------------------------------------------------------// //-------------------------------------------------------------//
@ -1670,12 +1670,12 @@ bool NppParameters::load()
issueFileName = nppLogNulContentCorruptionIssue; issueFileName = nppLogNulContentCorruptionIssue;
issueFileName += L".xml"; issueFileName += L".xml";
pathAppend(filePath, issueFileName); pathAppend(filePath, issueFileName);
_doNppLogNulContentCorruptionIssue = (PathFileExists(filePath.c_str()) == TRUE); _doNppLogNulContentCorruptionIssue = doesFileExist(filePath.c_str());
if (!_doNppLogNulContentCorruptionIssue) if (!_doNppLogNulContentCorruptionIssue)
{ {
filePath2 = _userPath; filePath2 = _userPath;
pathAppend(filePath2, issueFileName); pathAppend(filePath2, issueFileName);
_doNppLogNulContentCorruptionIssue = (PathFileExists(filePath2.c_str()) == TRUE); _doNppLogNulContentCorruptionIssue = doesFileExist(filePath2.c_str());
} }
//-------------------------------------------------------------// //-------------------------------------------------------------//
@ -1687,12 +1687,12 @@ bool NppParameters::load()
filePath = _nppPath; filePath = _nppPath;
std::wstring noRegForOSAppRestartTrigger = L"noRestartAutomatically.xml"; std::wstring noRegForOSAppRestartTrigger = L"noRestartAutomatically.xml";
pathAppend(filePath, noRegForOSAppRestartTrigger); pathAppend(filePath, noRegForOSAppRestartTrigger);
_isRegForOSAppRestartDisabled = (::PathFileExists(filePath.c_str()) == TRUE); _isRegForOSAppRestartDisabled = doesFileExist(filePath.c_str());
if (!_isRegForOSAppRestartDisabled) if (!_isRegForOSAppRestartDisabled)
{ {
filePath = _userPath; filePath = _userPath;
pathAppend(filePath, noRegForOSAppRestartTrigger); pathAppend(filePath, noRegForOSAppRestartTrigger);
_isRegForOSAppRestartDisabled = (::PathFileExists(filePath.c_str()) == TRUE); _isRegForOSAppRestartDisabled = doesFileExist(filePath.c_str());
} }
return isAllLoaded; return isAllLoaded;
@ -2285,7 +2285,7 @@ void NppParameters::setWorkingDir(const wchar_t * newPath)
} }
else else
{ {
if (PathFileExists(_nppGUI._defaultDirExp)) if (doesDirectoryExist(_nppGUI._defaultDirExp))
_currentDirectory = _nppGUI._defaultDirExp; _currentDirectory = _nppGUI._defaultDirExp;
else else
_currentDirectory = _nppPath.c_str(); _currentDirectory = _nppPath.c_str();
@ -3246,7 +3246,7 @@ void NppParameters::setCloudChoice(const wchar_t *pathChoice)
std::wstring cloudChoicePath = getSettingsFolder(); std::wstring cloudChoicePath = getSettingsFolder();
cloudChoicePath += L"\\cloud\\"; cloudChoicePath += L"\\cloud\\";
if (!PathFileExists(cloudChoicePath.c_str())) if (!doesDirectoryExist(cloudChoicePath.c_str()))
{ {
::CreateDirectory(cloudChoicePath.c_str(), NULL); ::CreateDirectory(cloudChoicePath.c_str(), NULL);
} }
@ -3263,7 +3263,7 @@ void NppParameters::removeCloudChoice()
std::wstring cloudChoicePath = getSettingsFolder(); std::wstring cloudChoicePath = getSettingsFolder();
cloudChoicePath += L"\\cloud\\choice"; cloudChoicePath += L"\\cloud\\choice";
if (PathFileExists(cloudChoicePath.c_str())) if (doesFileExist(cloudChoicePath.c_str()))
{ {
::DeleteFile(cloudChoicePath.c_str()); ::DeleteFile(cloudChoicePath.c_str());
} }
@ -3304,7 +3304,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// config.xml // config.xml
std::wstring cloudConfigPath = cloudSettingsPath; std::wstring cloudConfigPath = cloudSettingsPath;
pathAppend(cloudConfigPath, L"config.xml"); pathAppend(cloudConfigPath, L"config.xml");
if (!::PathFileExists(cloudConfigPath.c_str()) && _pXmlUserDoc) if (!doesFileExist(cloudConfigPath.c_str()) && _pXmlUserDoc)
{ {
isOK = _pXmlUserDoc->SaveFile(cloudConfigPath.c_str()); isOK = _pXmlUserDoc->SaveFile(cloudConfigPath.c_str());
if (!isOK) if (!isOK)
@ -3314,7 +3314,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// stylers.xml // stylers.xml
std::wstring cloudStylersPath = cloudSettingsPath; std::wstring cloudStylersPath = cloudSettingsPath;
pathAppend(cloudStylersPath, L"stylers.xml"); pathAppend(cloudStylersPath, L"stylers.xml");
if (!::PathFileExists(cloudStylersPath.c_str()) && _pXmlUserStylerDoc) if (!doesFileExist(cloudStylersPath.c_str()) && _pXmlUserStylerDoc)
{ {
isOK = _pXmlUserStylerDoc->SaveFile(cloudStylersPath.c_str()); isOK = _pXmlUserStylerDoc->SaveFile(cloudStylersPath.c_str());
if (!isOK) if (!isOK)
@ -3324,7 +3324,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// langs.xml // langs.xml
std::wstring cloudLangsPath = cloudSettingsPath; std::wstring cloudLangsPath = cloudSettingsPath;
pathAppend(cloudLangsPath, L"langs.xml"); pathAppend(cloudLangsPath, L"langs.xml");
if (!::PathFileExists(cloudLangsPath.c_str()) && _pXmlUserDoc) if (!doesFileExist(cloudLangsPath.c_str()) && _pXmlUserDoc)
{ {
isOK = _pXmlDoc->SaveFile(cloudLangsPath.c_str()); isOK = _pXmlDoc->SaveFile(cloudLangsPath.c_str());
if (!isOK) if (!isOK)
@ -3334,7 +3334,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// userDefineLang.xml // userDefineLang.xml
std::wstring cloudUserLangsPath = cloudSettingsPath; std::wstring cloudUserLangsPath = cloudSettingsPath;
pathAppend(cloudUserLangsPath, L"userDefineLang.xml"); pathAppend(cloudUserLangsPath, L"userDefineLang.xml");
if (!::PathFileExists(cloudUserLangsPath.c_str()) && _pXmlUserLangDoc) if (!doesFileExist(cloudUserLangsPath.c_str()) && _pXmlUserLangDoc)
{ {
isOK = _pXmlUserLangDoc->SaveFile(cloudUserLangsPath.c_str()); isOK = _pXmlUserLangDoc->SaveFile(cloudUserLangsPath.c_str());
if (!isOK) if (!isOK)
@ -3344,7 +3344,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// shortcuts.xml // shortcuts.xml
std::wstring cloudShortcutsPath = cloudSettingsPath; std::wstring cloudShortcutsPath = cloudSettingsPath;
pathAppend(cloudShortcutsPath, SHORTCUTSXML_FILENAME); pathAppend(cloudShortcutsPath, SHORTCUTSXML_FILENAME);
if (!::PathFileExists(cloudShortcutsPath.c_str()) && _pXmlShortcutDocA) if (!doesFileExist(cloudShortcutsPath.c_str()) && _pXmlShortcutDocA)
{ {
isOK = _pXmlShortcutDocA->SaveUnicodeFilePath(cloudShortcutsPath.c_str()); isOK = _pXmlShortcutDocA->SaveUnicodeFilePath(cloudShortcutsPath.c_str());
if (!isOK) if (!isOK)
@ -3354,7 +3354,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// contextMenu.xml // contextMenu.xml
std::wstring cloudContextMenuPath = cloudSettingsPath; std::wstring cloudContextMenuPath = cloudSettingsPath;
pathAppend(cloudContextMenuPath, L"contextMenu.xml"); pathAppend(cloudContextMenuPath, L"contextMenu.xml");
if (!::PathFileExists(cloudContextMenuPath.c_str()) && _pXmlContextMenuDocA) if (!doesFileExist(cloudContextMenuPath.c_str()) && _pXmlContextMenuDocA)
{ {
isOK = _pXmlContextMenuDocA->SaveUnicodeFilePath(cloudContextMenuPath.c_str()); isOK = _pXmlContextMenuDocA->SaveUnicodeFilePath(cloudContextMenuPath.c_str());
if (!isOK) if (!isOK)
@ -3364,7 +3364,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const std::wstring &
// nativeLang.xml // nativeLang.xml
std::wstring cloudNativeLangPath = cloudSettingsPath; std::wstring cloudNativeLangPath = cloudSettingsPath;
pathAppend(cloudNativeLangPath, L"nativeLang.xml"); pathAppend(cloudNativeLangPath, L"nativeLang.xml");
if (!::PathFileExists(cloudNativeLangPath.c_str()) && _pXmlNativeLangDocA) if (!doesFileExist(cloudNativeLangPath.c_str()) && _pXmlNativeLangDocA)
{ {
isOK = _pXmlNativeLangDocA->SaveUnicodeFilePath(cloudNativeLangPath.c_str()); isOK = _pXmlNativeLangDocA->SaveUnicodeFilePath(cloudNativeLangPath.c_str());
if (!isOK) if (!isOK)
@ -3429,7 +3429,7 @@ void NppParameters::writeDefaultUDL()
} }
else if (deleteAll) else if (deleteAll)
{ {
if (::PathFileExists(_userDefineLangPath.c_str())) if (doesFileExist(_userDefineLangPath.c_str()))
{ {
::DeleteFile(_userDefineLangPath.c_str()); ::DeleteFile(_userDefineLangPath.c_str());
} }
@ -3447,7 +3447,7 @@ void NppParameters::writeNonDefaultUDL()
{ {
// no need to save, delete file // no need to save, delete file
const wchar_t* docFilePath = udl._udlXmlDoc->Value(); const wchar_t* docFilePath = udl._udlXmlDoc->Value();
if (docFilePath && ::PathFileExists(docFilePath)) if (docFilePath && doesFileExist(docFilePath))
{ {
::DeleteFile(docFilePath); ::DeleteFile(docFilePath);
} }
@ -3596,7 +3596,7 @@ void NppParameters::writeSession(const Session & session, const wchar_t *fileNam
// //
wchar_t backupPathName[MAX_PATH]{}; wchar_t backupPathName[MAX_PATH]{};
BOOL doesBackupCopyExist = FALSE; BOOL doesBackupCopyExist = FALSE;
if (PathFileExists(sessionPathName)) if (doesFileExist(sessionPathName))
{ {
_tcscpy(backupPathName, sessionPathName); _tcscpy(backupPathName, sessionPathName);
_tcscat(backupPathName, SESSION_BACKUP_EXT); _tcscat(backupPathName, SESSION_BACKUP_EXT);
@ -3782,7 +3782,7 @@ void NppParameters::writeShortcuts()
::PathRemoveFileSpec(v852NoNeedShortcutsBackup); ::PathRemoveFileSpec(v852NoNeedShortcutsBackup);
::PathAppend(v852NoNeedShortcutsBackup, NONEEDSHORTCUTSXMLBACKUP_FILENAME); ::PathAppend(v852NoNeedShortcutsBackup, NONEEDSHORTCUTSXMLBACKUP_FILENAME);
if (!::PathFileExists(v852NoNeedShortcutsBackup)) if (!doesFileExist(v852NoNeedShortcutsBackup))
{ {
// Creat empty file v852NoNeedShortcutsBackup.xml for not giving warning, neither doing backup, in future use. // Creat empty file v852NoNeedShortcutsBackup.xml for not giving warning, neither doing backup, in future use.
HANDLE hFile = ::CreateFile(v852NoNeedShortcutsBackup, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE hFile = ::CreateFile(v852NoNeedShortcutsBackup, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@ -6321,7 +6321,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
pathAppend(themePath, L"themes\\"); pathAppend(themePath, L"themes\\");
pathAppend(themePath, xmlFileName); pathAppend(themePath, xmlFileName);
if (!isLocalOnly && ::PathFileExists(themePath.c_str()) == FALSE) if (!isLocalOnly && !doesFileExist(themePath.c_str()))
{ {
themePath = _nppPath; themePath = _nppPath;
pathAppend(themePath, L"themes\\"); pathAppend(themePath, L"themes\\");
@ -6333,14 +6333,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
themePath = isLocalOnly ? _nppPath : _userPath; themePath = isLocalOnly ? _nppPath : _userPath;
pathAppend(themePath, L"stylers.xml"); pathAppend(themePath, L"stylers.xml");
if (!isLocalOnly && ::PathFileExists(themePath.c_str()) == FALSE) if (!isLocalOnly && !doesFileExist(themePath.c_str()))
{ {
themePath = _nppPath; themePath = _nppPath;
pathAppend(themePath, L"stylers.xml"); pathAppend(themePath, L"stylers.xml");
} }
} }
if (::PathFileExists(themePath.c_str()) == TRUE) if (doesFileExist(themePath.c_str()))
{ {
_nppGUI._themeName.assign(themePath); _nppGUI._themeName.assign(themePath);
} }

View File

@ -262,14 +262,15 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it
bool isWow64Off = false; bool isWow64Off = false;
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
if (!PathFileExists(_fullPathName.c_str())) bool fileExists = doesFileExist(_fullPathName.c_str());
if (!fileExists)
{ {
nppParam.safeWow64EnableWow64FsRedirection(FALSE); nppParam.safeWow64EnableWow64FsRedirection(FALSE);
isWow64Off = true; isWow64Off = true;
} }
bool isOK = false; bool isOK = false;
if (_currentStatus == DOC_INACCESSIBLE && !PathFileExists(_fullPathName.c_str())) //document is absent on its first load - we set readonly and not dirty, and make it be as document which has been deleted if (_currentStatus == DOC_INACCESSIBLE && !fileExists) //document is absent on its first load - we set readonly and not dirty, and make it be as document which has been deleted
{ {
_currentStatus = DOC_DELETED;//DOC_INACCESSIBLE; _currentStatus = DOC_DELETED;//DOC_INACCESSIBLE;
_isInaccessible = true; _isInaccessible = true;
@ -279,7 +280,7 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
isOK = true; isOK = true;
} }
else if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName.c_str())) //document has been deleted else if (_currentStatus != DOC_DELETED && !fileExists) //document has been deleted
{ {
_currentStatus = DOC_DELETED; _currentStatus = DOC_DELETED;
_isFileReadOnly = false; _isFileReadOnly = false;
@ -288,7 +289,7 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it
doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
isOK = true; isOK = true;
} }
else if (_currentStatus == DOC_DELETED && PathFileExists(_fullPathName.c_str())) else if (_currentStatus == DOC_DELETED && fileExists)
{ //document has returned from its grave { //document has returned from its grave
if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0)
{ {
@ -326,7 +327,6 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it
{ {
if (res == 1) if (res == 1)
{ {
NppParameters& nppParam = NppParameters::getInstance();
if (nppParam.doNppLogNetworkDriveIssue()) if (nppParam.doNppLogNetworkDriveIssue())
{ {
wstring issueFn = nppLogNetworkDriveIssue; wstring issueFn = nppLogNetworkDriveIssue;
@ -692,7 +692,7 @@ BufferID FileManager::loadFile(const wchar_t* filename, Document doc, int encodi
//Get file size //Get file size
int64_t fileSize = -1; int64_t fileSize = -1;
const wchar_t* pPath = filename; const wchar_t* pPath = filename;
if (!::PathFileExists(pPath)) if (!doesFileExist(pPath))
{ {
pPath = backupFileName; pPath = backupFileName;
} }
@ -750,8 +750,8 @@ BufferID FileManager::loadFile(const wchar_t* filename, Document doc, int encodi
} }
} }
bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); bool isSnapshotMode = backupFileName != NULL && doesFileExist(backupFileName);
if (isSnapshotMode && !PathFileExists(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED if (isSnapshotMode && !doesFileExist(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED
{ {
wcscpy_s(fullpath, MAX_PATH, filename); // we restore fullpath with filename, in our case is "new #" wcscpy_s(fullpath, MAX_PATH, filename); // we restore fullpath with filename, in our case is "new #"
} }
@ -778,7 +778,7 @@ BufferID FileManager::loadFile(const wchar_t* filename, Document doc, int encodi
if (backupFileName != NULL) if (backupFileName != NULL)
{ {
newBuf->_backupFileName = backupFileName; newBuf->_backupFileName = backupFileName;
if (!PathFileExists(fullpath)) if (!doesFileExist(fullpath))
newBuf->_currentStatus = DOC_UNNAMED; newBuf->_currentStatus = DOC_UNNAMED;
} }
@ -899,7 +899,7 @@ bool FileManager::deleteFile(BufferID id)
// Make sure to form a string with double '\0' terminator. // Make sure to form a string with double '\0' terminator.
fileNamePath.append(1, '\0'); fileNamePath.append(1, '\0');
if (!PathFileExists(fileNamePath.c_str())) if (!doesFileExist(fileNamePath.c_str()))
return false; return false;
SHFILEOPSTRUCT fileOpStruct = {}; SHFILEOPSTRUCT fileOpStruct = {};
@ -1004,7 +1004,7 @@ bool FileManager::backupCurrentBuffer()
backupFilePath += L"\\backup\\"; backupFilePath += L"\\backup\\";
// if "backup" folder doesn't exist, create it. // if "backup" folder doesn't exist, create it.
if (!PathFileExists(backupFilePath.c_str())) if (!doesFileExist(backupFilePath.c_str()))
{ {
::CreateDirectory(backupFilePath.c_str(), NULL); ::CreateDirectory(backupFilePath.c_str(), NULL);
} }
@ -1079,7 +1079,7 @@ bool FileManager::backupCurrentBuffer()
{ {
if (buffer->isUntitled()) // "new #" file is saved successfully, then we replace its only physical existence by its temp if (buffer->isUntitled()) // "new #" file is saved successfully, then we replace its only physical existence by its temp
{ {
if (::PathFileExists(fullpath)) if (doesFileExist(fullpath))
::ReplaceFile(fullpath, fullpathTemp.c_str(), nullptr, REPLACEFILE_IGNORE_MERGE_ERRORS | REPLACEFILE_IGNORE_ACL_ERRORS, 0, 0); ::ReplaceFile(fullpath, fullpathTemp.c_str(), nullptr, REPLACEFILE_IGNORE_MERGE_ERRORS | REPLACEFILE_IGNORE_ACL_ERRORS, 0, 0);
else else
::MoveFileEx(fullpathTemp.c_str(), fullpath, MOVEFILE_REPLACE_EXISTING); ::MoveFileEx(fullpathTemp.c_str(), fullpath, MOVEFILE_REPLACE_EXISTING);
@ -1183,7 +1183,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
return SavingStatus::NotEnoughRoom; return SavingStatus::NotEnoughRoom;
} }
if (PathFileExists(fullpath)) if (doesFileExist(fullpath))
{ {
attrib = ::GetFileAttributes(fullpath); attrib = ::GetFileAttributes(fullpath);

View File

@ -504,9 +504,7 @@ void FileBrowser::openSelectFile()
_selectedNodeFullPath = getNodePath(selectedNode); _selectedNodeFullPath = getNodePath(selectedNode);
// test the path - if it's a file, open it, otherwise just fold or unfold it // test the path - if it's a file, open it, otherwise just fold or unfold it
if (!::PathFileExists(_selectedNodeFullPath.c_str())) if (!doesFileExist(_selectedNodeFullPath.c_str()))
return;
if (::PathIsDirectory(_selectedNodeFullPath.c_str()))
return; return;
::PostMessage(_hParent, NPPM_DOOPEN, 0, reinterpret_cast<LPARAM>(_selectedNodeFullPath.c_str())); ::PostMessage(_hParent, NPPM_DOOPEN, 0, reinterpret_cast<LPARAM>(_selectedNodeFullPath.c_str()));
@ -580,7 +578,7 @@ void FileBrowser::notified(LPNMHDR notification)
// Check the validity of modified file path // Check the validity of modified file path
tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
if (::PathFileExists(filePath->c_str())) if (doesPathExist(filePath->c_str()))
{ {
tvItem.iImage = INDEX_LEAF; tvItem.iImage = INDEX_LEAF;
tvItem.iSelectedImage = INDEX_LEAF; tvItem.iSelectedImage = INDEX_LEAF;
@ -802,7 +800,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
if (!selectedNode) return; if (!selectedNode) return;
wstring path = getNodePath(selectedNode); wstring path = getNodePath(selectedNode);
if (::PathFileExists(path.c_str())) if (doesPathExist(path.c_str()))
{ {
wchar_t cmdStr[1024] = {}; wchar_t cmdStr[1024] = {};
if (getNodeType(selectedNode) == browserNodeType_file) if (getNodeType(selectedNode) == browserNodeType_file)
@ -823,7 +821,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
selectedNode = _treeView.getParent(selectedNode); selectedNode = _treeView.getParent(selectedNode);
wstring path = getNodePath(selectedNode); wstring path = getNodePath(selectedNode);
if (::PathFileExists(path.c_str())) if (doesPathExist(path.c_str()))
{ {
Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str()); Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str());
cmd.run(nullptr, path.c_str()); cmd.run(nullptr, path.c_str());
@ -893,7 +891,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
if (!selectedNode) return; if (!selectedNode) return;
wstring path = getNodePath(selectedNode); wstring path = getNodePath(selectedNode);
if (::PathFileExists(path.c_str())) if (doesPathExist(path.c_str()))
::ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOWNORMAL); ::ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOWNORMAL);
} }
break; break;
@ -955,10 +953,7 @@ void FileBrowser::getDirectoryStructure(const wchar_t *dir, const std::vector<ws
void FileBrowser::addRootFolder(wstring rootFolderPath) void FileBrowser::addRootFolder(wstring rootFolderPath)
{ {
if (!::PathFileExists(rootFolderPath.c_str())) if (!doesDirectoryExist(rootFolderPath.c_str()))
return;
if (!::PathIsDirectory(rootFolderPath.c_str()))
return; return;
// make sure there's no '\' at the end // make sure there's no '\' at the end
@ -1203,7 +1198,7 @@ bool FileBrowser::addToTree(FilesToChange & group, HTREEITEM node)
group._files.erase(std::remove_if(group._files.begin(), group._files.end(), group._files.erase(std::remove_if(group._files.begin(), group._files.end(),
[&group](const auto & file) [&group](const auto & file)
{ {
return !::PathFileExists((group._commonPath + file).c_str()); return !doesPathExist((group._commonPath + file).c_str());
}), }),
group._files.end()); group._files.end());

View File

@ -275,7 +275,7 @@ bool FunctionListPanel::serialize(const wstring & outputFilename)
// Export function list from an existing file // Export function list from an existing file
bool exportFuncntionList = (NppParameters::getInstance()).doFunctionListExport(); bool exportFuncntionList = (NppParameters::getInstance()).doFunctionListExport();
if (exportFuncntionList && ::PathFileExists(fullFilePath)) if (exportFuncntionList && doesFileExist(fullFilePath))
{ {
fname2write = fullFilePath; fname2write = fullFilePath;
fname2write += L".result"; fname2write += L".result";
@ -540,9 +540,9 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
if (!doLocalConf) if (!doLocalConf)
{ {
if (!PathFileExists(funcListXmlPath.c_str())) if (!doesDirectoryExist(funcListXmlPath.c_str()))
{ {
if (PathFileExists(funcListDefaultXmlPath.c_str())) if (doesDirectoryExist(funcListDefaultXmlPath.c_str()))
{ {
::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE); ::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE);
_funcParserMgr.init(funcListXmlPath, funcListDefaultXmlPath, ppEditView); _funcParserMgr.init(funcListXmlPath, funcListDefaultXmlPath, ppEditView);
@ -555,7 +555,7 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
} }
else else
{ {
if (PathFileExists(funcListDefaultXmlPath.c_str())) if (doesDirectoryExist(funcListDefaultXmlPath.c_str()))
{ {
_funcParserMgr.init(funcListDefaultXmlPath, funcListDefaultXmlPath, ppEditView); _funcParserMgr.init(funcListDefaultXmlPath, funcListDefaultXmlPath, ppEditView);
} }

View File

@ -619,7 +619,7 @@ bool loadFromJson(std::vector<PluginUpdateInfo*>& pl, wstring& verStr, const jso
PluginUpdateInfo::PluginUpdateInfo(const wstring& fullFilePath, const wstring& filename) PluginUpdateInfo::PluginUpdateInfo(const wstring& fullFilePath, const wstring& filename)
{ {
if (!::PathFileExists(fullFilePath.c_str())) if (!doesFileExist(fullFilePath.c_str()))
return; return;
_fullFilePath = fullFilePath; _fullFilePath = fullFilePath;
@ -644,12 +644,12 @@ bool PluginsAdminDlg::initFromJson()
return false; return false;
} }
if (!::PathFileExists(_pluginListFullPath.c_str())) if (!doesFileExist(_pluginListFullPath.c_str()))
{ {
return false; return false;
} }
if (!::PathFileExists(_updaterFullPath.c_str())) if (!doesFileExist(_updaterFullPath.c_str()))
{ {
return false; return false;
} }

View File

@ -5614,7 +5614,7 @@ intptr_t CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, L
if (withCloud) if (withCloud)
{ {
// detect validation of path // detect validation of path
if (!::PathFileExists(nppGUI._cloudPath.c_str())) if (!doesDirectoryExist(nppGUI._cloudPath.c_str()))
errMsg = L"Invalid path"; errMsg = L"Invalid path";
} }
@ -5690,7 +5690,7 @@ intptr_t CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, L
::SendDlgItemMessage(_hSelf, IDC_CLOUDPATH_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast<LPARAM>(inputDir)); ::SendDlgItemMessage(_hSelf, IDC_CLOUDPATH_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast<LPARAM>(inputDir));
::ExpandEnvironmentStrings(inputDir, inputDirExpanded, MAX_PATH); ::ExpandEnvironmentStrings(inputDir, inputDirExpanded, MAX_PATH);
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
if (::PathFileExists(inputDirExpanded)) if (doesDirectoryExist(inputDirExpanded))
{ {
nppGUI._cloudPath = inputDirExpanded; nppGUI._cloudPath = inputDirExpanded;
nppParams.setCloudChoice(inputDirExpanded); nppParams.setCloudChoice(inputDirExpanded);

View File

@ -337,7 +337,7 @@ bool ProjectPanel::openWorkSpace(const wchar_t *projectFileName, bool force)
return false; return false;
} }
if (!::PathFileExists(projectFileName)) if (!doesFileExist(projectFileName))
{ {
delete pXmlDocProject; delete pXmlDocProject;
return false; return false;
@ -538,7 +538,7 @@ bool ProjectPanel::buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem)
const wchar_t *strValue = (childNode->ToElement())->Attribute(L"name"); const wchar_t *strValue = (childNode->ToElement())->Attribute(L"name");
wstring fullPath = getAbsoluteFilePath(strValue); wstring fullPath = getAbsoluteFilePath(strValue);
wchar_t *strValueLabel = ::PathFindFileName(strValue); wchar_t *strValueLabel = ::PathFindFileName(strValue);
int iImage = ::PathFileExists(fullPath.c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; int iImage = doesFileExist(fullPath.c_str()) ? INDEX_LEAF : INDEX_LEAF_INVALID;
wstring* fullPathStr = new wstring(fullPath); wstring* fullPathStr = new wstring(fullPath);
fullPathStrs.push_back(fullPathStr); fullPathStrs.push_back(fullPathStr);
@ -574,7 +574,7 @@ void ProjectPanel::openSelectFile()
if (nType == nodeType_file && fn) if (nType == nodeType_file && fn)
{ {
tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
if (::PathFileExists(fn->c_str())) if (doesFileExist(fn->c_str()))
{ {
::PostMessage(_hParent, NPPM_DOOPEN, 0, reinterpret_cast<LPARAM>(fn->c_str())); ::PostMessage(_hParent, NPPM_DOOPEN, 0, reinterpret_cast<LPARAM>(fn->c_str()));
tvItem.iImage = INDEX_LEAF; tvItem.iImage = INDEX_LEAF;
@ -643,7 +643,7 @@ void ProjectPanel::notified(LPNMHDR notification)
// Check the validity of modified file path // Check the validity of modified file path
tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
if (::PathFileExists(filePath->c_str())) if (doesFileExist(filePath->c_str()))
{ {
tvItem.iImage = INDEX_LEAF; tvItem.iImage = INDEX_LEAF;
tvItem.iSelectedImage = INDEX_LEAF; tvItem.iSelectedImage = INDEX_LEAF;
@ -1073,7 +1073,7 @@ void ProjectPanel::popupMenuCmd(int cmdID)
} }
} }
if (::PathFileExists(_workSpaceFilePath.c_str())) if (doesFileExist(_workSpaceFilePath.c_str()))
{ {
openWorkSpace(_workSpaceFilePath.c_str(), forceOpen); openWorkSpace(_workSpaceFilePath.c_str(), forceOpen);
} }
@ -1179,7 +1179,7 @@ void ProjectPanel::popupMenuCmd(int cmdID)
*fn = newValue; *fn = newValue;
wchar_t *strValueLabel = ::PathFindFileName(fn->c_str()); wchar_t *strValueLabel = ::PathFindFileName(fn->c_str());
wcscpy_s(textBuffer, strValueLabel); wcscpy_s(textBuffer, strValueLabel);
int iImage = ::PathFileExists(fn->c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; int iImage = doesFileExist(fn->c_str()) ? INDEX_LEAF : INDEX_LEAF_INVALID;
tvItem.iImage = tvItem.iSelectedImage = iImage; tvItem.iImage = tvItem.iSelectedImage = iImage;
SendMessage(_treeView.getHSelf(), TVM_SETITEM, 0, reinterpret_cast<LPARAM>(&tvItem)); SendMessage(_treeView.getHSelf(), TVM_SETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
setWorkSpaceDirty(true); setWorkSpaceDirty(true);

View File

@ -91,7 +91,7 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
locator += L"\\"; locator += L"\\";
locator += icoUnit._id; locator += icoUnit._id;
locator += ext; locator += ext;
if (::PathFileExists(locator.c_str())) if (doesFileExist(locator.c_str()))
{ {
_customIconVect.push_back(iconLocator(HLIST_DEFAULT, i, locator)); _customIconVect.push_back(iconLocator(HLIST_DEFAULT, i, locator));
_customIconVect.push_back(iconLocator(HLIST_DEFAULT2, i, locator)); _customIconVect.push_back(iconLocator(HLIST_DEFAULT2, i, locator));
@ -106,7 +106,7 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
locator_dis += icoUnit._id; locator_dis += icoUnit._id;
locator_dis += disabled_suffix; locator_dis += disabled_suffix;
locator_dis += ext; locator_dis += ext;
if (::PathFileExists(locator_dis.c_str())) if (doesFileExist(locator_dis.c_str()))
{ {
_customIconVect.push_back(iconLocator(HLIST_DISABLE, i, locator_dis)); _customIconVect.push_back(iconLocator(HLIST_DISABLE, i, locator_dis));
_customIconVect.push_back(iconLocator(HLIST_DISABLE2, i, locator_dis)); _customIconVect.push_back(iconLocator(HLIST_DISABLE2, i, locator_dis));

View File

@ -624,7 +624,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
std::wstring updaterParams = L"-v"; std::wstring updaterParams = L"-v";
updaterParams += VERSION_INTERNAL_VALUE; updaterParams += VERSION_INTERNAL_VALUE;
bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE); bool isUpExist = nppGui._doesExistUpdater = doesFileExist(updaterFullPath.c_str());
if (doUpdateNpp) // check more detail if (doUpdateNpp) // check more detail
{ {