============================================================================= InstallFileWatching()
| 6242 | // |
| 6243 | // |
| 6244 | void 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() |
no outgoing calls
no test coverage detected