diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 7208cbb4..f0decae1 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -77,12 +77,10 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) // We've received a notification in the queue. { DWORD dwAction; - CStringW wstrFilename; + generic_string fn; // Process all available changes, ignore User actions - while (changes.Pop(dwAction, wstrFilename)) + while (changes.Pop(dwAction, fn)) { - generic_string fn = wstrFilename.GetString(); - // Fix monitoring files which are under root problem size_t pos = fn.find(TEXT("\\\\")); if (pos == 2) diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index a53b0a0c..fa347032 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -1353,7 +1353,7 @@ DWORD WINAPI FolderUpdater::watching(void *params) // We've received a notification in the queue. { DWORD dwAction; - CStringW wstrFilename; + generic_string wstrFilename; // Process all available changes, ignore User actions while (changes.Pop(dwAction, wstrFilename)) { @@ -1364,14 +1364,14 @@ DWORD WINAPI FolderUpdater::watching(void *params) switch (dwAction) { case FILE_ACTION_ADDED: - file2Change.push_back(wstrFilename.GetString()); + file2Change.push_back(wstrFilename); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_ADDFILE, reinterpret_cast(nullptr), reinterpret_cast(&file2Change)); oldName = TEXT(""); break; case FILE_ACTION_REMOVED: - file2Change.push_back(wstrFilename.GetString()); + file2Change.push_back(wstrFilename); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RMFILE, reinterpret_cast(nullptr), reinterpret_cast(&file2Change)); oldName = TEXT(""); @@ -1382,14 +1382,14 @@ DWORD WINAPI FolderUpdater::watching(void *params) break; case FILE_ACTION_RENAMED_OLD_NAME: - oldName = wstrFilename.GetString(); + oldName = wstrFilename; break; case FILE_ACTION_RENAMED_NEW_NAME: if (not oldName.empty()) { file2Change.push_back(oldName); - file2Change.push_back(wstrFilename.GetString()); + file2Change.push_back(wstrFilename); //thisFolderUpdater->updateTree(dwAction, file2Change); ::SendMessage((thisFolderUpdater->_pFileBrowser)->getHSelf(), FB_RNFILE, reinterpret_cast(nullptr), reinterpret_cast(&file2Change)); } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp index 0351630d..36a5057b 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.cpp @@ -85,13 +85,13 @@ void CReadDirectoryChanges::AddDirectory( LPCTSTR szDirectory, BOOL bWatchSubtre QueueUserAPC(CReadChangesServer::AddDirectoryProc, m_hThread, (ULONG_PTR)pRequest); } -void CReadDirectoryChanges::Push(DWORD dwAction, CStringW& wstrFilename) +void CReadDirectoryChanges::Push(DWORD dwAction, std::wstring& wstrFilename) { TDirectoryChangeNotification dirChangeNotif = TDirectoryChangeNotification(dwAction, wstrFilename); m_Notifications.push(dirChangeNotif); } -bool CReadDirectoryChanges::Pop(DWORD& dwAction, CStringW& wstrFilename) +bool CReadDirectoryChanges::Pop(DWORD& dwAction, std::wstring& wstrFilename) { TDirectoryChangeNotification pair; if (!m_Notifications.pop(pair)) diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h index f1ae2c47..1500f6d3 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChanges.h @@ -44,7 +44,6 @@ #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #include -#include #include #include @@ -53,7 +52,7 @@ using namespace std; #include "ThreadSafeQueue.h" -typedef pair TDirectoryChangeNotification; +typedef pair TDirectoryChangeNotification; namespace ReadDirectoryChangesPrivate { @@ -98,7 +97,7 @@ namespace ReadDirectoryChangesPrivate /// // We've received a notification in the queue. /// { /// DWORD dwAction; -/// CStringW wstrFilename; +/// std::wstring wstrFilename; /// while (changes.Pop(dwAction, wstrFilename)) /// wprintf(L"%s %s\n", ExplainAction(dwAction), wstrFilename); /// } @@ -143,10 +142,10 @@ public: /// HANDLE GetWaitHandle() { return m_Notifications.GetWaitHandle(); } - bool Pop(DWORD& dwAction, CStringW& wstrFilename); + bool Pop(DWORD& dwAction, std::wstring& wstrFilename); // "Push" is for usage by ReadChangesRequest. Not intended for external usage. - void Push(DWORD dwAction, CStringW& wstrFilename); + void Push(DWORD dwAction, std::wstring& wstrFilename); unsigned int GetThreadId() { return m_dwThreadId; } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp index 765160e5..fcd1223f 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp @@ -71,7 +71,7 @@ bool CReadChangesRequest::OpenDirectory() return true; m_hDirectory = ::CreateFileW( - m_wstrDirectory, // pointer to the file name + m_wstrDirectory.c_str(), // pointer to the file name FILE_LIST_DIRECTORY, // access (read/write) mode FILE_SHARE_READ // share mode | FILE_SHARE_WRITE @@ -144,15 +144,15 @@ void CReadChangesRequest::ProcessNotification() { FILE_NOTIFY_INFORMATION& fni = (FILE_NOTIFY_INFORMATION&)*pBase; - CStringW wstrFilename(fni.FileName, fni.FileNameLength/sizeof(wchar_t)); + std::wstring wstrFilename(fni.FileName, fni.FileNameLength/sizeof(wchar_t)); // Handle a trailing backslash, such as for a root directory. - if (wstrFilename.Right(1) != L"\\") + if (!wstrFilename.empty() && wstrFilename.back() != L'\\') wstrFilename = m_wstrDirectory + L"\\" + wstrFilename; else wstrFilename = m_wstrDirectory + wstrFilename; // If it could be a short filename, expand it. - LPCWSTR wszFilename = PathFindFileNameW(wstrFilename); + LPCWSTR wszFilename = PathFindFileNameW(wstrFilename.c_str()); int len = lstrlenW(wszFilename); // The maximum length of an 8.3 filename is twelve, including the dot. if (len <= 12 && wcschr(wszFilename, L'~')) @@ -160,7 +160,7 @@ void CReadChangesRequest::ProcessNotification() // Convert to the long filename form. Unfortunately, this // does not work for deletions, so it's an imperfect fix. wchar_t wbuf[MAX_PATH]; - if (::GetLongPathNameW(wstrFilename, wbuf, _countof(wbuf)) > 0) + if (::GetLongPathNameW(wstrFilename.c_str(), wbuf, _countof(wbuf)) > 0) wstrFilename = wbuf; } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h index cd7beeb7..f5998238 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h @@ -75,9 +75,9 @@ protected: LPOVERLAPPED lpOverlapped); // I/O information buffer // Parameters from the caller for ReadDirectoryChangesW(). - DWORD m_dwFilterFlags; - BOOL m_bIncludeChildren; - CStringW m_wstrDirectory; + DWORD m_dwFilterFlags; + BOOL m_bIncludeChildren; + std::wstring m_wstrDirectory; // Result of calling CreateFile(). HANDLE m_hDirectory;