ReactOS 0.4.15-dev-8191-gbc6c731
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 NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by CDirectoryWatcher::RequestAddWatcher().

◆ _NotificationCompletion()

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

Definition at line 281 of file CDirectoryWatcher.cpp.

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

Referenced by CDirectoryWatcher::RestartWatching().

◆ _RequestAllTerminationAPC()

static void NTAPI _RequestAllTerminationAPC ( ULONG_PTR  Parameter)
static

Definition at line 64 of file CDirectoryWatcher.cpp.

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

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}

Referenced by CDirectoryWatcher::RequestTermination().

◆ ConvertActionToEvent()

static DWORD ConvertActionToEvent ( DWORD  Action,
BOOL  fDir 
)
static

Definition at line 113 of file CDirectoryWatcher.cpp.

114{
115 switch (Action)
116 {
118 return (fDir ? SHCNE_MKDIR : SHCNE_CREATE);
120 return (fDir ? SHCNE_RMDIR : SHCNE_DELETE);
122 return (fDir ? SHCNE_UPDATEDIR : SHCNE_UPDATEITEM);
124 break;
126 return (fDir ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM);
127 default:
128 break;
129 }
130 return 0;
131}
#define SHCNE_RMDIR
Definition: shlobj.h:1887
#define SHCNE_DELETE
Definition: shlobj.h:1885
#define SHCNE_MKDIR
Definition: shlobj.h:1886
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1896
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1883
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1895
#define SHCNE_CREATE
Definition: shlobj.h:1884
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1900
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
#define FILE_ACTION_MODIFIED
#define FILE_ACTION_RENAMED_OLD_NAME
#define FILE_ACTION_REMOVED
#define FILE_ACTION_RENAMED_NEW_NAME
#define FILE_ACTION_ADDED

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}
#define INFINITE
Definition: serial.h:102
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148

Referenced by CDirectoryWatcher::CreateAPCThread().

◆ GetFilterFromEvents()

static DWORD GetFilterFromEvents ( DWORD  fEvents)
static

Definition at line 296 of file CDirectoryWatcher.cpp.

297{
298 // FIXME
303}
#define FILE_NOTIFY_CHANGE_SIZE
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FILE_NOTIFY_CHANGE_CREATION
#define FILE_NOTIFY_CHANGE_DIR_NAME

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}
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
static const WCHAR path1[]
Definition: path.c:28
static const WCHAR path2[]
Definition: path.c:29
#define SHCNF_FLUSH
Definition: shlobj.h:1921
#define SHCNF_PATHW
Definition: shlobj.h:1918
#define SHCNE_INTERRUPT
Definition: shlobj.h:1908

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