HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_FileMonitor.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_FileMonitor.h UT library (C++)
7  *
8  * COMMENTS: Check if files in a given directory have been changed.
9  *
10  *
11  */
12 
13 #ifndef __UT_FileMonitor_h__
14 #define __UT_FileMonitor_h__
15 
16 #include "UT_API.h"
17 #include "UT_StringArray.h"
18 #include "UT_Array.h"
19 #include "UT_IntArray.h"
20 #include "UT_Lock.h"
21 #include "UT_Signal.h"
22 #include "UT_Thread.h"
23 
24 
25 class UT_FileMonitor;
26 class UT_String;
27 class UT_Thread;
28 
29 typedef bool ( *UTmonitorFunc )( void *op , const char* filename );
30 
32 {
33 public:
35  virtual ~UT_FileMonitor();
36 
37  // add file to the monitor list
38  bool addFile( const char *filename,
39  UTmonitorFunc func, void *data );
40  // remove file from the monitor list
41  bool removeFile( void *data , const char* filename=0 );
42 
43  const UT_StringArray &getFileList() const { return myMonitoredFiles; } ;
44 
45  void startMyThread();
46  void stopMyThread();
47 
48  void getDirectory( const char *str, UT_String &dir );
49 
50  void executeCallbacks( const char* file );
51 
52 
53 protected:
55 
56 
57 private:
58  static void* monitorFiles( void *data );
59 
60  void removeMonitoredFile( const char *filename );
61  void removeFileEntry( int index );
62 
63 
64  UT_Lock myFileLock;
66  UT_StringArray myOPFileRoots;
67  UT_StringArray myOPFiles;
68  UT_StringArray myDirList;
69  UT_StringArray myMonitoredFiles;
70  UT_IntArray myFHandle;
71  UT_IntArray myFTime;
72 
73  UT_Thread *myThread;
74  bool myQuitThread;
75 };
76 
78 
79 
80 #endif //__UT_FileMonitor_h__
bool(* UTmonitorFunc)(void *op, const char *filename)
#define UT_API
Definition: UT_API.h:12
const UT_StringArray & getFileList() const
GLboolean * data
Definition: glcorearb.h:130
GLenum func
Definition: glcorearb.h:782
UT_API UT_FileMonitor * UTgetFileMonitor()
GLuint index
Definition: glcorearb.h:785
UT_Array< UTmonitorFunc > myCallbacks