forked from notepad-plus-plus/notepad-plus-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for notepad-plus-plus#3142 and notepad-plus-plus#4955
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
PowerEditor/src/WinControls/ReadDirectoryChanges/ReadFileChanges.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "ReadFileChanges.h" | ||
|
||
|
||
|
||
CReadFileChanges::CReadFileChanges() | ||
{ | ||
_szFile = NULL; | ||
_dwNotifyFilter = 0; | ||
} | ||
|
||
|
||
CReadFileChanges::~CReadFileChanges() | ||
{ | ||
} | ||
|
||
|
||
BOOL CReadFileChanges::DetectChanges() { | ||
|
||
WIN32_FILE_ATTRIBUTE_DATA fInfo; | ||
BOOL rValue = FALSE; | ||
::GetFileAttributesEx(_szFile, GetFileExInfoStandard, &fInfo); | ||
|
||
if ((_dwNotifyFilter & FILE_NOTIFY_CHANGE_SIZE) && (fInfo.nFileSizeHigh != _lastFileInfo.nFileSizeHigh || fInfo.nFileSizeLow != _lastFileInfo.nFileSizeLow)) { | ||
rValue = TRUE; | ||
} | ||
|
||
if ((_dwNotifyFilter & FILE_NOTIFY_CHANGE_LAST_WRITE) && (fInfo.ftLastWriteTime.dwHighDateTime != _lastFileInfo.ftLastWriteTime.dwHighDateTime || fInfo.ftLastWriteTime.dwLowDateTime != _lastFileInfo.ftLastWriteTime.dwLowDateTime)) { | ||
rValue = TRUE; | ||
} | ||
|
||
_lastFileInfo = fInfo; | ||
return rValue; | ||
} | ||
|
||
void CReadFileChanges::AddFile(LPCTSTR szFile, DWORD dwNotifyFilter) | ||
{ | ||
_szFile = szFile; | ||
_dwNotifyFilter = dwNotifyFilter; | ||
::GetFileAttributesEx(szFile, GetFileExInfoStandard, &_lastFileInfo); | ||
} | ||
|
||
|
||
void CReadFileChanges::Terminate() | ||
{ | ||
_szFile = NULL; | ||
_dwNotifyFilter = 0; | ||
} |
29 changes: 29 additions & 0 deletions
29
PowerEditor/src/WinControls/ReadDirectoryChanges/ReadFileChanges.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
|
||
#include <stdio.h> | ||
|
||
#ifndef VC_EXTRALEAN | ||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers | ||
#endif | ||
|
||
|
||
#include <windows.h> | ||
|
||
|
||
class CReadFileChanges | ||
{ | ||
public: | ||
CReadFileChanges(); | ||
~CReadFileChanges(); | ||
void AddFile(LPCTSTR szDirectory, DWORD dwNotifyFilter); | ||
BOOL DetectChanges(); | ||
void Terminate(); | ||
|
||
private: | ||
LPCTSTR _szFile; | ||
DWORD _dwNotifyFilter; | ||
WIN32_FILE_ATTRIBUTE_DATA _lastFileInfo; | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters