aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/WatcherWin32.hpp
blob: 71e13be9464df9c8bf121095c484808adb312824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef EFSW_WATCHERWIN32_HPP
#define EFSW_WATCHERWIN32_HPP

#include <efsw/FileInfo.hpp>
#include <efsw/FileWatcherImpl.hpp>

#if EFSW_PLATFORM == EFSW_PLATFORM_WIN32

#include <windows.h>

#ifdef EFSW_COMPILER_MSVC
#pragma comment( lib, "comctl32.lib" )
#pragma comment( lib, "user32.lib" )
#pragma comment( lib, "ole32.lib" )

// disable secure warnings
#pragma warning( disable : 4996 )
#endif

namespace efsw {

class WatcherWin32;

/// Internal watch data
struct WatcherStructWin32 {
	OVERLAPPED Overlapped;
	WatcherWin32* Watch;
};

struct sLastModifiedEvent {
	FileInfo file;
	std::string fileName;
};

bool RefreshWatch( WatcherStructWin32* pWatch );

void CALLBACK WatchCallback( DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped );

void DestroyWatch( WatcherStructWin32* pWatch );

WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive, DWORD NotifyFilter,
								 HANDLE iocp );

class WatcherWin32 : public Watcher {
  public:
	WatcherWin32() :
		Struct( NULL ),
		DirHandle( NULL ),
		lParam( 0 ),
		NotifyFilter( 0 ),
		StopNow( false ),
		Watch( NULL ),
		DirName( NULL ) {}

	WatcherStructWin32* Struct;
	HANDLE DirHandle;
	BYTE Buffer
		[63 *
		 1024]; // do NOT make this bigger than 64K because it will fail if the folder being watched
				// is on the network! (see
				// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365465(v=vs.85).aspx)
	LPARAM lParam;
	DWORD NotifyFilter;
	bool StopNow;
	FileWatcherImpl* Watch;
	char* DirName;
	sLastModifiedEvent LastModifiedEvent;
};

} // namespace efsw

#endif

#endif