aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/efsw.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/efsw/efsw.h')
-rwxr-xr-xsrc/3rdParty/efsw/efsw.h151
1 files changed, 151 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/efsw.h b/src/3rdParty/efsw/efsw.h
new file mode 100755
index 0000000..28e63e2
--- /dev/null
+++ b/src/3rdParty/efsw/efsw.h
@@ -0,0 +1,151 @@
1/**
2 @author Sepul Sepehr Taghdisian
3
4 Copyright (c) 2013 Martin Lucas Golini
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23
24 This software is a fork of the "simplefilewatcher" by James Wynn (james@jameswynn.com)
25 http://code.google.com/p/simplefilewatcher/ also MIT licensed.
26*/
27/** This is the C API wrapper of EFSW */
28#ifndef ESFW_H
29#define ESFW_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#if defined(_WIN32)
36 #ifdef EFSW_DYNAMIC
37 // Windows platforms
38 #ifdef EFSW_EXPORTS
39 // From DLL side, we must export
40 #define EFSW_API __declspec(dllexport)
41 #else
42 // From client application side, we must import
43 #define EFSW_API __declspec(dllimport)
44 #endif
45 #else
46 // No specific directive needed for static build
47 #ifndef EFSW_API
48 #define EFSW_API
49 #endif
50 #endif
51#else
52 #if ( __GNUC__ >= 4 ) && defined( EFSW_EXPORTS )
53 #define EFSW_API __attribute__ ((visibility("default")))
54 #endif
55
56 // Other platforms don't need to define anything
57 #ifndef EFSW_API
58 #define EFSW_API
59 #endif
60#endif
61
62/// Type for a watch id
63typedef long efsw_watchid;
64
65/// Type for watcher
66typedef void* efsw_watcher;
67
68enum efsw_action
69{
70 EFSW_ADD = 1, /// Sent when a file is created or renamed
71 EFSW_DELETE = 2, /// Sent when a file is deleted or renamed
72 EFSW_MODIFIED = 3, /// Sent when a file is modified
73 EFSW_MOVED = 4 /// Sent when a file is moved
74};
75
76enum efsw_error
77{
78 EFSW_NOTFOUND = -1,
79 EFSW_REPEATED = -2,
80 EFSW_OUTOFSCOPE = -3,
81 EFSW_NOTREADABLE = -4,
82 EFSW_REMOTE = -5,
83 EFSW_UNSPECIFIED = -6
84};
85
86/// Basic interface for listening for file events.
87typedef void (*efsw_pfn_fileaction_callback) (
88 efsw_watcher watcher,
89 efsw_watchid watchid,
90 const char* dir,
91 const char* filename,
92 enum efsw_action action,
93 const char* old_filename,
94 void* param
95);
96
97/**
98 * Creates a new file-watcher
99 * @param generic_mode Force the use of the Generic file watcher
100 */
101efsw_watcher EFSW_API efsw_create(int generic_mode);
102
103/// Release the file-watcher and unwatch any directories
104void EFSW_API efsw_release(efsw_watcher watcher);
105
106/// Retreive last error occured by file-watcher
107EFSW_API const char* efsw_getlasterror();
108
109/// Add a directory watch. Same as the other addWatch, but doesn't have recursive option.
110/// For backwards compatibility.
111/// On error returns WatchID with Error type.
112efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
113 efsw_pfn_fileaction_callback callback_fn, int recursive, void* param);
114
115/// Remove a directory watch. This is a brute force search O(nlogn).
116void EFSW_API efsw_removewatch(efsw_watcher watcher, const char* directory);
117
118/// Remove a directory watch. This is a map lookup O(logn).
119void EFSW_API efsw_removewatch_byid(efsw_watcher watcher, efsw_watchid watchid);
120
121/// Starts watching ( in other thread )
122void EFSW_API efsw_watch(efsw_watcher watcher);
123
124/**
125 * Allow recursive watchers to follow symbolic links to other directories
126 * followSymlinks is disabled by default
127 */
128void EFSW_API efsw_follow_symlinks(efsw_watcher watcher, int enable);
129
130/** @return If can follow symbolic links to directorioes */
131int EFSW_API efsw_follow_symlinks_isenabled(efsw_watcher watcher);
132
133/**
134 * When enable this it will allow symlinks to watch recursively out of the pointed directory.
135 * follorSymlinks must be enabled to this work.
136 * For example, added symlink to /home/folder, and the symlink points to /, this by default is not allowed,
137 * it's only allowed to symlink anything from /home/ and deeper. This is to avoid great levels of recursion.
138 * Enabling this could lead in infinite recursion, and crash the watcher ( it will try not to avoid this ).
139 * Buy enabling out of scope links, it will allow this behavior.
140 * allowOutOfScopeLinks are disabled by default.
141 */
142void EFSW_API efsw_allow_outofscopelinks(efsw_watcher watcher, int allow);
143
144/// @return Returns if out of scope links are allowed
145int EFSW_API efsw_outofscopelinks_isallowed(efsw_watcher watcher);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif