ReactOS  0.4.15-dev-3163-gf17c2c0
CDirectoryWatcher.cpp File Reference
#include "shelldesktop.h"
#include "CDirectoryWatcher.h"
#include <process.h>
#include <assert.h>
Include dependency graph for CDirectoryWatcher.cpp:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   0x1000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shcn)
 
static void NotifyFileSystemChange (LONG wEventId, LPCWSTR path1, LPCWSTR path2)
 
static unsigned __stdcall DirectoryWatcherThreadFuncAPC (void *)
 
static void NTAPI _AddDirectoryProcAPC (ULONG_PTR Parameter)
 
static void NTAPI _RequestTerminationAPC (ULONG_PTR Parameter)
 
static void NTAPI _RequestAllTerminationAPC (ULONG_PTR Parameter)
 
static DWORD ConvertActionToEvent (DWORD Action, BOOL fDir)
 
static void CALLBACK _NotificationCompletion (DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)
 
static DWORD GetFilterFromEvents (DWORD fEvents)
 

Variables

static HANDLE s_hThreadAPC = NULL
 
static BOOL s_fTerminateAllWatchers = FALSE
 
static BYTE s_buffer [BUFFER_SIZE]
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   0x1000

Definition at line 28 of file CDirectoryWatcher.cpp.

Function Documentation

◆ _AddDirectoryProcAPC()

static void NTAPI _AddDirectoryProcAPC ( ULONG_PTR  Parameter)
static

Definition at line 46 of file CDirectoryWatcher.cpp.

47 {
48  CDirectoryWatcher *pDirectoryWatcher = (CDirectoryWatcher *)Parameter;
49  assert(pDirectoryWatcher != NULL);
50 
51  pDirectoryWatcher->RestartWatching();
52 }
#define assert(x)
Definition: debug.h:53
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define NULL
Definition: types.h:112

Referenced by CDirectoryWatcher::RequestAddWatcher().

◆ _NotificationCompletion()

static void CALLBACK _NotificationCompletion ( DWORD  dwErrorCode,
DWORD  dwNumberOfBytesTransfered,
LPOVERLAPPED  lpOverlapped 
)
static

Definition at line 282 of file CDirectoryWatcher.cpp.

285 {
286  // MSDN: The hEvent member of the OVERLAPPED structure is not used by the
287  // system in this case, so you can use it yourself. We do just this, storing
288  // a pointer to the working struct in the overlapped structure.
289  CDirectoryWatcher *pDirectoryWatcher = (CDirectoryWatcher *)lpOverlapped->hEvent;
290  assert(pDirectoryWatcher != NULL);
291 
292  pDirectoryWatcher->ReadCompletion(dwErrorCode, dwNumberOfBytesTransfered);
293 }
#define assert(x)
Definition: debug.h:53
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
#define NULL
Definition: types.h:112
void ReadCompletion(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered)

Referenced by CDirectoryWatcher::RestartWatching().

◆ _RequestAllTerminationAPC()

static void NTAPI _RequestAllTerminationAPC ( ULONG_PTR  Parameter)
static

Definition at line 64 of file CDirectoryWatcher.cpp.

65 {
69 }
static HANDLE s_hThreadAPC
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
#define NULL
Definition: types.h:112
static BOOL s_fTerminateAllWatchers

Referenced by CDirectoryWatcher::RequestAllWatchersTermination().

◆ _RequestTerminationAPC()

static void NTAPI _RequestTerminationAPC ( ULONG_PTR  Parameter)
static

Definition at line 55 of file CDirectoryWatcher.cpp.

56 {
57  CDirectoryWatcher *pDirectoryWatcher = (CDirectoryWatcher *)Parameter;
58  assert(pDirectoryWatcher != NULL);
59 
60  pDirectoryWatcher->QuitWatching();
61 }
#define assert(x)
Definition: debug.h:53
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define NULL
Definition: types.h:112

Referenced by CDirectoryWatcher::RequestTermination().

◆ ConvertActionToEvent()

static DWORD ConvertActionToEvent ( DWORD  Action,
BOOL  fDir 
)
static

Definition at line 114 of file CDirectoryWatcher.cpp.

115 {
116  switch (Action)
117  {
118  case FILE_ACTION_ADDED:
119  return (fDir ? SHCNE_MKDIR : SHCNE_CREATE);
120  case FILE_ACTION_REMOVED:
121  return (fDir ? SHCNE_RMDIR : SHCNE_DELETE);
123  return (fDir ? SHCNE_UPDATEDIR : SHCNE_UPDATEITEM);
125  break;
127  return (fDir ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM);
128  default:
129  break;
130  }
131  return 0;
132 }
#define SHCNE_MKDIR
Definition: shlobj.h:1732
#define SHCNE_RMDIR
Definition: shlobj.h:1733
#define FILE_ACTION_RENAMED_OLD_NAME
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1746
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1729
#define FILE_ACTION_MODIFIED
#define FILE_ACTION_REMOVED
#define FILE_ACTION_RENAMED_NEW_NAME
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
#define SHCNE_DELETE
Definition: shlobj.h:1731
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1741
#define FILE_ACTION_ADDED
#define SHCNE_CREATE
Definition: shlobj.h:1730
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1742

Referenced by CDirectoryWatcher::ProcessNotification().

◆ DirectoryWatcherThreadFuncAPC()

static unsigned __stdcall DirectoryWatcherThreadFuncAPC ( void )
static

Definition at line 32 of file CDirectoryWatcher.cpp.

33 {
35  {
36 #if 1 // FIXME: This is a HACK
38 #else
40 #endif
41  }
42  return 0;
43 }
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define TRUE
Definition: types.h:120
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
static BOOL s_fTerminateAllWatchers
#define INFINITE
Definition: serial.h:102

Referenced by CDirectoryWatcher::CreateAPCThread().

◆ GetFilterFromEvents()

static DWORD GetFilterFromEvents ( DWORD  fEvents)
static

Definition at line 297 of file CDirectoryWatcher.cpp.

298 {
299  // FIXME
304 }
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define FILE_NOTIFY_CHANGE_CREATION

Referenced by CDirectoryWatcher::RestartWatching().

◆ NotifyFileSystemChange()

static void NotifyFileSystemChange ( LONG  wEventId,
LPCWSTR  path1,
LPCWSTR  path2 
)
inlinestatic

Definition at line 16 of file CDirectoryWatcher.cpp.

17 {
19 }
static const WCHAR path2[]
Definition: path.c:29
#define SHCNE_INTERRUPT
Definition: shlobj.h:1754
static const WCHAR path1[]
Definition: path.c:28
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define SHCNF_FLUSH
Definition: shlobj.h:1767
#define SHCNF_PATHW
Definition: shlobj.h:1764

Referenced by CDirectoryWatcher::ProcessNotification(), and CDirectoryWatcher::ReadCompletion().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shcn  )

Variable Documentation

◆ s_buffer

◆ s_fTerminateAllWatchers

BOOL s_fTerminateAllWatchers = FALSE
static

◆ s_hThreadAPC