You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**efsw** is a C++ cross-platform file system watcher and notifier.
4
7
5
8
**efsw** monitors the file system asynchronously for changes to files and directories by watching a list of specified paths, and raises events when a directory or file change.
@@ -19,8 +22,8 @@ Entropia File System Watcher
19
22
* OS-independent generic watcher
20
23
(polling the disk for directory snapshots and comparing them periodically)
21
24
22
-
If any of the backend fails to start by any reason, it will fallback to the OS-independent implementation.
23
-
This should never happen, except for the Kqueue implementation, see `Platform limitations and clarifications`.
25
+
If any of the backend fails to start for any reason, it will fallback to the OS-independent implementation.
26
+
This should never happen, except for the Kqueue implementation; see `Platform limitations and clarifications`.
24
27
25
28
**Code License**
26
29
--------------
@@ -31,39 +34,41 @@ This should never happen, except for the Kqueue implementation, see `Platform li
31
34
32
35
```c++
33
36
// Inherits from the abstract listener class, and implements the the file action handler
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Added"
45
+
<< std::endl;
46
+
break;
47
+
case efsw::Actions::Delete:
48
+
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Delete"
49
+
<< std::endl;
50
+
break;
51
+
case efsw::Actions::Modified:
52
+
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Modified"
53
+
<< std::endl;
54
+
break;
55
+
case efsw::Actions::Moved:
56
+
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Moved from ("
57
+
<< oldFilename << ")" << std::endl;
58
+
break;
59
+
default:
60
+
std::cout << "Should never happen!" << std::endl;
61
+
}
62
+
}
59
63
};
60
64
61
65
// Create the file system watcher instance
62
-
// efsw::FileWatcher allow a first boolean parameter that indicates if it should start with the generic file watcher instead of the platform specific backend
63
-
efsw::FileWatcher * fileWatcher = new efsw::FileWatcher();
66
+
// efsw::FileWatcher allow a first boolean parameter that indicates if it should start with the
67
+
// generic file watcher instead of the platform specific backend
68
+
efsw::FileWatcher* fileWatcher = new efsw::FileWatcher();
64
69
65
70
// Create the instance of your efsw::FileWatcherListener implementation
66
-
UpdateListener* listener = new UpdateListener();
71
+
UpdateListener* listener = new UpdateListener();
67
72
68
73
// Add a folder to watch, and get the efsw::WatchID
69
74
// It will watch the /tmp folder recursively ( the third parameter indicates that is recursive )
// You can also call removeWatch by passing the watch path ( it must end with an slash or backslash in windows, since that's how internally it's saved )
89
+
// You can also call removeWatch by passing the watch path ( it must end with an slash or backslash
90
+
// in windows, since that's how internally it's saved )
81
91
fileWatcher->removeWatch( watchID2 );
82
92
```
83
93
@@ -87,21 +97,21 @@ None :)
87
97
88
98
**Compiling**
89
99
------------
90
-
To generate project files you will need to [download and install](http://industriousone.com/premake/download) [Premake](http://industriousone.com/what-premake)
100
+
To generate project files you will need to [download and install](https://premake.github.io/download) [Premake](https://premake.github.io/docs/What-Is-Premake)
91
101
92
-
Then you can generate the project for your platform just going to the project directory where the premake4.lua file is located and then execute:
102
+
Then you can generate the project for your platform by just going to the project directory where the premake4.lua file is located and executing:
93
103
94
-
`premake4 gmake` to generate project Makefiles, then `cd make/*YOURPLATFORM*/`, and finally `make` or `make config=release` ( it will generate the static lib, the shared lib and the test application ).
104
+
`premake5 gmake2` to generate project Makefiles, then `cd make/*YOURPLATFORM*/`, and finally `make` or `make config=release_x86_64` ( it will generate the static lib, the shared lib and the test application ).
95
105
96
-
or
106
+
or
97
107
98
-
`premake4 vs2010` to generate Visual Studio 2010 project.
108
+
`premake5 vs2022` to generate Visual Studio 2022 project.
99
109
100
110
or
101
111
102
-
`premake4 xcode4` to generate Xcode 4 project.
112
+
`premake5 xcode4` to generate Xcode 4 project.
103
113
104
-
There is also a cmake file that i don't oficially support but it works just fine, provided by [Mohammed Nafees](https://bitbucket.org/binaryking).
114
+
There is also a cmake file that I don't officially support but it works just fine, provided by [Mohammed Nafees](https://github.com/mnafees) and improved by [Eugene Shalygin](https://github.com/zeule).
105
115
106
116
**Platform limitations and clarifications**
107
117
-------------------------------------------
@@ -112,21 +122,21 @@ handleFileAction returns UTF-8 strings in all platforms.
112
122
113
123
Windows and FSEvents Mac OS X implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
114
124
115
-
Kqueue implementation is limited by the maximun number of file descriptors allowed per process by the OS, in the case of reaching the file descriptors limit ( in BSD around 18000 and in OS X around 10240 ) it will fallback to the generic file watcher.
125
+
Kqueue implementation is limited by the maximum number of file descriptors allowed per process by the OS. In the case of reaching the file descriptors limit ( in BSD around 18000 and in OS X around 10240 ), it will fallback to the generic file watcher.
116
126
117
-
OS X will only use Kqueue if OS X version is below to 10.5, and this implementation needs to be compiled separately from the OS X >= 10.5 implementation. Since there's no way to compile FSEvents backend in OS X below 10.5.
127
+
OS X will use only Kqueue if the OS X version is below 10.5. This implementation needs to be compiled separately from the OS X >= 10.5 implementation, since there's no way to compile FSEvents backend in OS X below 10.5.
118
128
119
-
FSEvents for OS X Lion and beyond in some cases will generate more actions that in reality ocurred, since fine-grained implementation of FSEvents doesn't give the order of the actions retrieved, in some cases i need to guess/aproximate the order of them.
129
+
FSEvents for OS X Lion and beyond in some cases will generate more actions than in reality ocurred, since fine-grained implementation of FSEvents doesn't give the order of the actions retrieved. In some cases I need to guess/approximate the order of them.
120
130
121
131
Generic watcher relies on the inode information to detect file and directories renames/move. Since Windows has no concept of inodes as Unix platforms do, there is no current reliable way of determining file/directory movement on Windows without help from the Windows API ( this is replaced with Add/Delete events ).
122
132
123
-
Linux versions below 2.6.13 are not supported, since inotify wasn't implemented yet. I'm not interested in support older kernels, since i don't see the point. If someone needs this open an issue in the issue tracker and i may consider implenent a dnotify backend.
133
+
Linux versions below 2.6.13 are not supported, since inotify wasn't implemented yet. I'm not interested in supporting older kernels, since I don't see the point. If someone needs this, open an issue in the issue tracker and I may consider implementing a dnotify backend.
124
134
125
-
OS-independent watcher, Kqueue and FSEvents for OS X below 10.5 keep cache of the directories structures, to be able to detect changes in the directories. This means that there's a memory overhead for this backends.
135
+
OS-independent watcher, Kqueue and FSEvents for OS X below 10.5 keep cache of the directories structures, to be able to detect changes in the directories. This means that there's a memory overhead for these backends.
126
136
127
137
**Useful information**
128
138
--------------------
129
-
The project also comes with a C API wrapper, contributed by [Sepul Sepehr Taghdisian](https://bitbucket.org/sepul).
139
+
The project also comes with a C API wrapper, contributed by [Sepul Sepehr Taghdisian](https://github.com/septag).
130
140
131
141
There's a string manipulation class not exposed in the efsw header ( efsw::String ) that can be used to make string encoding conversion.
0 commit comments