Skip to content

Commit 1164bb9

Browse files
committed
Merge branch 'master' into modernize
2 parents d98a5f7 + 9df3c0c commit 1164bb9

16 files changed

+277
-102
lines changed

.ecode/project_build.json

+69-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"linux-debug": {
33
"build": [
44
{
5-
"args": " --thread-sanitizer --verbose gmake2",
5+
"args": "--thread-sanitizer --verbose gmake2",
66
"command": "premake5",
77
"working_dir": ""
88
},
@@ -101,6 +101,74 @@
101101
}
102102
}
103103
},
104+
"macos-debug": {
105+
"build": [
106+
{
107+
"args": "--thread-sanitizer --verbose gmake2",
108+
"command": "premake5",
109+
"working_dir": ""
110+
},
111+
{
112+
"args": "-j${nproc} -C make/macosx",
113+
"command": "make",
114+
"working_dir": ""
115+
}
116+
],
117+
"build_types": [],
118+
"clean": [
119+
{
120+
"args": "",
121+
"command": "",
122+
"working_dir": ""
123+
}
124+
],
125+
"config": {
126+
"clear_sys_env": false
127+
},
128+
"os": [
129+
"macos"
130+
],
131+
"output_parser": {
132+
"config": {
133+
"preset": "generic",
134+
"relative_file_paths": true
135+
}
136+
}
137+
},
138+
"macos-release": {
139+
"build": [
140+
{
141+
"args": "gmake2",
142+
"command": "premake5",
143+
"working_dir": ""
144+
},
145+
{
146+
"args": "-j${nproc} -C make/macosx -e config=release_arm64",
147+
"command": "make",
148+
"working_dir": ""
149+
}
150+
],
151+
"build_types": [],
152+
"clean": [
153+
{
154+
"args": "",
155+
"command": "",
156+
"working_dir": ""
157+
}
158+
],
159+
"config": {
160+
"clear_sys_env": false
161+
},
162+
"os": [
163+
"macos"
164+
],
165+
"output_parser": {
166+
"config": {
167+
"preset": "generic",
168+
"relative_file_paths": true
169+
}
170+
}
171+
},
104172
"mingw-debug": {
105173
"build": [
106174
{

.github/workflows/main.yml

+11-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
run: |
1212
sudo apt-get update
1313
sudo apt-get install -y wget
14-
wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz
15-
tar xvzf premake-5.0.0-alpha14-linux.tar.gz
14+
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz
15+
tar xvzf premake-5.0.0-beta2-linux.tar.gz
1616
- name: Build
1717
run: |
1818
./premake5 --verbose gmake2
@@ -24,29 +24,27 @@ jobs:
2424
- uses: actions/checkout@v2
2525
- name: Install dependencies
2626
run: |
27-
brew install wget
28-
wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-macosx.tar.gz
29-
tar -xzf premake-5.0.0-alpha14-macosx.tar.gz
27+
brew install premake
3028
- name: Build
3129
run: |
32-
./premake5 --verbose gmake2
33-
make -C make/macosx/ -j`nproc` all
30+
premake5 --verbose gmake2
31+
make -C make/macosx/ -j$(sysctl -n hw.ncpu) all
3432
Windows:
35-
runs-on: windows-2019
33+
runs-on: windows-latest
3634
env:
37-
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
35+
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\
3836
steps:
3937
- uses: actions/checkout@v2
4038
- name: Install dependencies
4139
shell: powershell
4240
run: |
43-
Invoke-WebRequest -Uri "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-windows.zip" -OutFile "premake-5.0.0-alpha14-windows.zip"
44-
Expand-Archive -DestinationPath . -Path premake-5.0.0-alpha14-windows.zip
41+
Invoke-WebRequest -Uri "https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-windows.zip" -OutFile "premake-5.0.0-beta2-windows.zip"
42+
Expand-Archive -DestinationPath . -Path premake-5.0.0-beta2-windows.zip
4543
- name: Create project
4644
shell: powershell
4745
run: |
48-
./premake5.exe --verbose vs2019
46+
./premake5.exe --verbose vs2022
4947
- name: Build
5048
shell: cmd
5149
run: |
52-
"%MSBUILD_PATH%\MSBuild.exe" .\make\windows\efsw.sln -m
50+
"%MSBUILD_PATH%\MSBuild.exe" .\make\windows\efsw.sln -m /p:Platform="x64"

README.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Entropia File System Watcher ![efsw](https://web.ensoft.dev/efsw/efsw-logo.svg)
1515

1616
* Windows via [I/O Completion Ports](http://en.wikipedia.org/wiki/IOCP)
1717

18-
* Mac OS X via [FSEvents](http://en.wikipedia.org/wiki/FSEvents) or [kqueue](http://en.wikipedia.org/wiki/Kqueue)
18+
* macOS via [FSEvents](http://en.wikipedia.org/wiki/FSEvents) or [kqueue](http://en.wikipedia.org/wiki/Kqueue)
1919

2020
* FreeBSD/BSD via [kqueue](http://en.wikipedia.org/wiki/Kqueue)
2121

@@ -113,34 +113,40 @@ or
113113
114114
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).
115115
116+
**Packages**
117+
------------
118+
119+
Community has been kind and contributed the recipes for different popular packages systems: [Conan](https://conan.io/center/recipes/efsw), [vcpkg](https://vcpkg.io/en/package/efsw), [xmake-repo](https://github.com/xmake-io/xmake-repo/blob/dev/packages/e/efsw/xmake.lua). I don't personally maintain those packages so they could be not up to date, but they tend to be quite up to date.
120+
116121
**Platform limitations and clarifications**
117122
-------------------------------------------
118123
119124
Directory paths are expected to be encoded as UTF-8 strings in all platforms.
120125
121126
handleFileAction returns UTF-8 strings in all platforms.
122127
123-
Windows and FSEvents Mac OS X implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
128+
File modification events may be reported multiple times during a copy operation, typically after each write flush. This behavior is inherent to how file watchers operate and cannot be altered. If you need to open the file after receiving a modification event, it is recommended to wait for a reasonable period of time after the last event to avoid potential issues.
124129
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.
130+
Windows and FSEvents macOS implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
126131
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.
132+
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 macOS around 10240 ), it will fallback to the generic file watcher.
128133
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.
134+
macOS will use only Kqueue if the macOS version is below 10.5. This implementation needs to be compiled separately from the macOS >= 10.5 implementation, since there's no way to compile FSEvents backend in macOS below 10.5.
135+
136+
FSEvents for macOS 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.
130137
131138
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 ).
132139
133140
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.
134141
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.
142+
OS-independent watcher, Kqueue and FSEvents for macOS 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.
136143
137144
**Useful information**
138145
--------------------
139146
The project also comes with a C API wrapper, contributed by [Sepul Sepehr Taghdisian](https://github.com/septag).
140147
141148
There's a string manipulation class not exposed in the efsw header ( efsw::String ) that can be used to make string encoding conversion.
142149
143-
144150
**Clarifications**
145151
----------------
146152

include/efsw/efsw.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ enum efsw_option
9595
/// For Windows, per default all events are captured but we might only be interested
9696
/// in a subset; the value of the option should be set to a bitwise or'ed set of
9797
/// FILE_NOTIFY_CHANGE_* flags.
98-
EFSW_OPT_WIN_NOTIFY_FILTER = 2
98+
EFSW_OPT_WIN_NOTIFY_FILTER = 2,
99+
/// For macOS (FSEvents backend), per default all modified event types are capture but we might
100+
// only be interested in a subset; the value of the option should be set to a set of bitwise
101+
// from:
102+
// kFSEventStreamEventFlagItemFinderInfoMod
103+
// kFSEventStreamEventFlagItemModified
104+
// kFSEventStreamEventFlagItemInodeMetaMod
105+
// Default configuration will set the 3 flags
106+
EFSW_OPT_MAC_MODIFIED_FILTER = 3,
99107
};
100108

101109
/// Basic interface for listening for file events.
@@ -131,7 +139,7 @@ EFSW_API void efsw_clearlasterror();
131139

132140
/// Add a directory watch
133141
/// On error returns WatchID with Error type.
134-
efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
142+
efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
135143
efsw_pfn_fileaction_callback callback_fn, int recursive, void* param);
136144

137145
/// Add a directory watch, specifying options

include/efsw/efsw.hpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,15 @@ enum Option {
135135
/// For Windows, per default all events are captured but we might only be interested
136136
/// in a subset; the value of the option should be set to a bitwise or'ed set of
137137
/// FILE_NOTIFY_CHANGE_* flags.
138-
WinNotifyFilter = 2
138+
WinNotifyFilter = 2,
139+
/// For macOS (FSEvents backend), per default all modified event types are capture but we might
140+
// only be interested in a subset; the value of the option should be set to a set of bitwise
141+
// from:
142+
// kFSEventStreamEventFlagItemFinderInfoMod
143+
// kFSEventStreamEventFlagItemModified
144+
// kFSEventStreamEventFlagItemInodeMetaMod
145+
// Default configuration will set the 3 flags
146+
MacModifiedFilter = 3,
139147
};
140148
}
141149
typedef Options::Option Option;
@@ -168,7 +176,7 @@ class EFSW_API FileWatcher {
168176
/// @param recursive Set this to true to include subdirectories
169177
/// @param options Allows customization of a watcher
170178
/// @return Returns the watch id for the directory or, on error, a WatchID with Error type.
171-
WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive,
179+
WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive,
172180
const std::vector<WatcherOption> &options );
173181

174182
/// Remove a directory watch. This is a brute force search O(nlogn).

0 commit comments

Comments
 (0)