Make better variable names & coding style

This commit is contained in:
Don HO 2020-02-26 01:37:00 +01:00
parent 66893f980f
commit 40b49d0b66
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -58,13 +58,13 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE; const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE;
// Create the monitor and add directory to watch. // Create the monitor and add directory to watch.
CReadDirectoryChanges changes; CReadDirectoryChanges dirChanges;
changes.AddDirectory(folderToMonitor, true, dwNotificationFlags); dirChanges.AddDirectory(folderToMonitor, true, dwNotificationFlags);
CReadFileChanges fChanges; CReadFileChanges fileChanges;
fChanges.AddFile(fullFileName, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE); fileChanges.AddFile(fullFileName, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE);
HANDLE changeHandles[] = { buf->getMonitoringEvent(), changes.GetWaitHandle() }; HANDLE changeHandles[] = { buf->getMonitoringEvent(), dirChanges.GetWaitHandle() };
bool toBeContinued = true; bool toBeContinued = true;
@ -74,17 +74,19 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
switch (waitStatus) switch (waitStatus)
{ {
case WAIT_OBJECT_0 + 0: case WAIT_OBJECT_0 + 0:
// Mutex was signaled. User removes this folder or file browser is closed // Mutex was signaled. User removes this folder or file browser is closed
{
toBeContinued = false; toBeContinued = false;
}
break; break;
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
// We've received a notification in the queue. // We've received a notification in the queue.
{ {
DWORD dwAction; DWORD dwAction;
generic_string fn; generic_string fn;
// Process all available changes, ignore User actions // Process all available changes, ignore User actions
while (changes.Pop(dwAction, fn)) while (dirChanges.Pop(dwAction, fn))
{ {
// Fix monitoring files which are under root problem // Fix monitoring files which are under root problem
size_t pos = fn.find(TEXT("\\\\")); size_t pos = fn.find(TEXT("\\\\"));
@ -106,11 +108,14 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
} }
} }
break; break;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
if (fChanges.DetectChanges()) { {
if (fileChanges.DetectChanges())
::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast<WPARAM>(buf), 0); ::PostMessage(h, NPPM_INTERNAL_RELOADSCROLLTOEND, reinterpret_cast<WPARAM>(buf), 0);
} }
break; break;
case WAIT_IO_COMPLETION: case WAIT_IO_COMPLETION:
// Nothing to do. // Nothing to do.
break; break;
@ -119,8 +124,8 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
// Just for sample purposes. The destructor will // Just for sample purposes. The destructor will
// call Terminate() automatically. // call Terminate() automatically.
changes.Terminate(); dirChanges.Terminate();
fChanges.Terminate(); fileChanges.Terminate();
delete monitorInfo; delete monitorInfo;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }