-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiskMonitorWaitThread.h
77 lines (67 loc) · 3.01 KB
/
DiskMonitorWaitThread.h
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
75
76
77
//---------------------------------------------------------------------------
#ifndef DiskMonitorWaitThreadH
#define DiskMonitorWaitThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <stdlib.h>
#include "Filectrl.hpp"
#include "DiskMonitorFileInfo.h"
//---------------------------------------------------------------------------
#define MIN_TIMEOUT 5
//---------------------------------------------------------------------------
enum TMonitorChangedItem {MCI_UNKNOWN, MCI_PRIVATE, MCI_CREATE, MCI_DELETE, MCI_MODIFY, MCI_RENAME, MCI_ATTR, MCI_SIZE, MCI_DATE};
//---------------------------------------------------------------------------
//typedef void __fastcall (__closure *TMonitorCallback)(AnsiString Dir, AnsiString Filename, AnsiString Oldname, TMonitorFileInfo *Info, TMonitorFileInfo *Oldinfo, TMonitorChangedItem Item);
typedef void __fastcall (__closure *TMonitorCallback)(void);
//---------------------------------------------------------------------------
class TMonitorWaitThread : public TThread
{
private:
TMonitorCallback FMultiplexer;
AnsiString *FMonitorPath;
long FTimeout;
TStringList *FileList;
AnsiString *AffectedFile;
AnsiString *AuxFile;
HANDLE MyHandle;
bool WatchSubtree;
bool AllFiles;
FILE_NOTIFY_INFORMATION *NotBuf;
OVERLAPPED *Overlap;
HANDLE DirHandle;
DWORD CompKey;
DWORD FilterCond;
DWORD BytesBack;
unsigned int NotBufSize;
TMonitorChangedItem FEvent;
TMonitorFileInfo *EventInfo;
TMonitorFileInfo *EventHistory;
protected:
long __fastcall GetTimeout();
void __fastcall SetTimeout(long sec);
int __fastcall GetFileCount();
AnsiString __fastcall GetMonitorPath();
void __fastcall SetMonitorPath(AnsiString p);
void __fastcall Execute();
void __fastcall SetupMonitoring();
void __fastcall ShutdownMonitoring();
bool __fastcall IsSpecificFile(AnsiString fname);
int __fastcall GetSpecificFileIndex(AnsiString fname);
bool __fastcall DirExists(AnsiString dir);
void __fastcall LoadFileInfo(int i, AnsiString fn);
void __fastcall ClearFileInfo();
void __fastcall LoadAllFiles();
public:
__fastcall TMonitorWaitThread(AnsiString Dir, bool SubTree, bool SpecificFiles, TMonitorCallback multip);
__fastcall ~TMonitorWaitThread();
void __fastcall AddFilename(AnsiString *fname);
TMonitorFileInfo * __fastcall GetEventFileInfo();
TMonitorFileInfo * __fastcall GetEventFileHistory();
TMonitorChangedItem __fastcall GetEvent();
__property Terminated;
__property int FileCount = {read=GetFileCount};
__property long Timeout = {read=GetTimeout, write=SetTimeout};
__property AnsiString MonitorPath = {read=GetMonitorPath, write=SetMonitorPath};
};
//---------------------------------------------------------------------------
#endif