MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / InstallFileWatching

Function InstallFileWatching

src/Notepad2.c:6244–6293  ·  view source on GitHub ↗

============================================================================= InstallFileWatching()

Source from the content-addressed store, hash-verified

6242//
6243//
6244void InstallFileWatching ( LPCWSTR lpszFile )
6245{
6246 WCHAR tchDirectory[MAX_PATH];
6247 HANDLE hFind;
6248 // Terminate
6249 if ( !iFileWatchingMode || !lpszFile || lstrlen ( lpszFile ) == 0 ) {
6250 if ( bRunningWatch ) {
6251 if ( hChangeHandle ) {
6252 FindCloseChangeNotification ( hChangeHandle );
6253 hChangeHandle = NULL;
6254 }
6255 KillTimer ( NULL, ID_WATCHTIMER );
6256 bRunningWatch = FALSE;
6257 dwChangeNotifyTime = 0;
6258 }
6259 return;
6260 }
6261 // Install
6262 else {
6263 // Terminate previous watching
6264 if ( bRunningWatch ) {
6265 if ( hChangeHandle ) {
6266 FindCloseChangeNotification ( hChangeHandle );
6267 hChangeHandle = NULL;
6268 }
6269 dwChangeNotifyTime = 0;
6270 }
6271 // No previous watching installed, so launch the timer first
6272 else {
6273 SetTimer ( NULL, ID_WATCHTIMER, dwFileCheckInverval, WatchTimerProc );
6274 }
6275 lstrcpy ( tchDirectory, lpszFile );
6276 PathRemoveFileSpec ( tchDirectory );
6277 // Save data of current file
6278 hFind = FindFirstFile ( szCurFile, &fdCurFile );
6279 if ( hFind != INVALID_HANDLE_VALUE ) {
6280 FindClose ( hFind );
6281 } else {
6282 ZeroMemory ( &fdCurFile, sizeof ( WIN32_FIND_DATA ) );
6283 }
6284 hChangeHandle = FindFirstChangeNotification ( tchDirectory, FALSE,
6285 FILE_NOTIFY_CHANGE_FILE_NAME | \
6286 FILE_NOTIFY_CHANGE_DIR_NAME | \
6287 FILE_NOTIFY_CHANGE_ATTRIBUTES | \
6288 FILE_NOTIFY_CHANGE_SIZE | \
6289 FILE_NOTIFY_CHANGE_LAST_WRITE );
6290 bRunningWatch = TRUE;
6291 dwChangeNotifyTime = 0;
6292 }
6293}
6294//=============================================================================
6295//
6296// WatchTimerProc()

Callers 5

InitInstanceFunction · 0.85
MainWndProcFunction · 0.85
MsgCommandFunction · 0.85
_FileLoadFunction · 0.85
FileSaveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected