ReactOS 0.4.15-dev-7659-ga55345b
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:323

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}
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 114 of file CDirectoryWatcher.cpp.

115{
116 switch (Action)
117 {
119 return (fDir ? SHCNE_MKDIR : SHCNE_CREATE);
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_RMDIR
Definition: shlobj.h:1812
#define SHCNE_DELETE
Definition: shlobj.h:1810
#define SHCNE_MKDIR
Definition: shlobj.h:1811
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1821
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1808
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1820
#define SHCNE_CREATE
Definition: shlobj.h:1809
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1825
_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 297 of file CDirectoryWatcher.cpp.

298{
299 // FIXME
304}
#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:1846
#define SHCNF_PATHW
Definition: shlobj.h:1843
#define SHCNE_INTERRUPT
Definition: shlobj.h:1833

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