Skip to content

Commit

Permalink
Merge branch 'master' into modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Nov 18, 2024
2 parents d98a5f7 + 9df3c0c commit 1164bb9
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 102 deletions.
70 changes: 69 additions & 1 deletion .ecode/project_build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"linux-debug": {
"build": [
{
"args": " --thread-sanitizer --verbose gmake2",
"args": "--thread-sanitizer --verbose gmake2",
"command": "premake5",
"working_dir": ""
},
Expand Down Expand Up @@ -101,6 +101,74 @@
}
}
},
"macos-debug": {
"build": [
{
"args": "--thread-sanitizer --verbose gmake2",
"command": "premake5",
"working_dir": ""
},
{
"args": "-j${nproc} -C make/macosx",
"command": "make",
"working_dir": ""
}
],
"build_types": [],
"clean": [
{
"args": "",
"command": "",
"working_dir": ""
}
],
"config": {
"clear_sys_env": false
},
"os": [
"macos"
],
"output_parser": {
"config": {
"preset": "generic",
"relative_file_paths": true
}
}
},
"macos-release": {
"build": [
{
"args": "gmake2",
"command": "premake5",
"working_dir": ""
},
{
"args": "-j${nproc} -C make/macosx -e config=release_arm64",
"command": "make",
"working_dir": ""
}
],
"build_types": [],
"clean": [
{
"args": "",
"command": "",
"working_dir": ""
}
],
"config": {
"clear_sys_env": false
},
"os": [
"macos"
],
"output_parser": {
"config": {
"preset": "generic",
"relative_file_paths": true
}
}
},
"mingw-debug": {
"build": [
{
Expand Down
24 changes: 11 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y wget
wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz
tar xvzf premake-5.0.0-alpha14-linux.tar.gz
wget https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-linux.tar.gz
tar xvzf premake-5.0.0-beta2-linux.tar.gz
- name: Build
run: |
./premake5 --verbose gmake2
Expand All @@ -24,29 +24,27 @@ jobs:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
brew install wget
wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-macosx.tar.gz
tar -xzf premake-5.0.0-alpha14-macosx.tar.gz
brew install premake
- name: Build
run: |
./premake5 --verbose gmake2
make -C make/macosx/ -j`nproc` all
premake5 --verbose gmake2
make -C make/macosx/ -j$(sysctl -n hw.ncpu) all
Windows:
runs-on: windows-2019
runs-on: windows-latest
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
MSBUILD_PATH: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v2
- name: Install dependencies
shell: powershell
run: |
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"
Expand-Archive -DestinationPath . -Path premake-5.0.0-alpha14-windows.zip
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"
Expand-Archive -DestinationPath . -Path premake-5.0.0-beta2-windows.zip
- name: Create project
shell: powershell
run: |
./premake5.exe --verbose vs2019
./premake5.exe --verbose vs2022
- name: Build
shell: cmd
run: |
"%MSBUILD_PATH%\MSBuild.exe" .\make\windows\efsw.sln -m
"%MSBUILD_PATH%\MSBuild.exe" .\make\windows\efsw.sln -m /p:Platform="x64"
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Entropia File System Watcher ![efsw](https://web.ensoft.dev/efsw/efsw-logo.svg)

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

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

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

Expand Down Expand Up @@ -113,34 +113,40 @@ or
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).
**Packages**
------------
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.
**Platform limitations and clarifications**
-------------------------------------------
Directory paths are expected to be encoded as UTF-8 strings in all platforms.
handleFileAction returns UTF-8 strings in all platforms.
Windows and FSEvents Mac OS X implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
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.
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.
Windows and FSEvents macOS implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
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.
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.
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.
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.
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.
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 ).
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.
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.
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.
**Useful information**
--------------------
The project also comes with a C API wrapper, contributed by [Sepul Sepehr Taghdisian](https://github.com/septag).
There's a string manipulation class not exposed in the efsw header ( efsw::String ) that can be used to make string encoding conversion.
**Clarifications**
----------------
Expand Down
12 changes: 10 additions & 2 deletions include/efsw/efsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ enum efsw_option
/// For Windows, per default all events are captured but we might only be interested
/// in a subset; the value of the option should be set to a bitwise or'ed set of
/// FILE_NOTIFY_CHANGE_* flags.
EFSW_OPT_WIN_NOTIFY_FILTER = 2
EFSW_OPT_WIN_NOTIFY_FILTER = 2,
/// For macOS (FSEvents backend), per default all modified event types are capture but we might
// only be interested in a subset; the value of the option should be set to a set of bitwise
// from:
// kFSEventStreamEventFlagItemFinderInfoMod
// kFSEventStreamEventFlagItemModified
// kFSEventStreamEventFlagItemInodeMetaMod
// Default configuration will set the 3 flags
EFSW_OPT_MAC_MODIFIED_FILTER = 3,
};

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

/// Add a directory watch
/// On error returns WatchID with Error type.
efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
efsw_pfn_fileaction_callback callback_fn, int recursive, void* param);

/// Add a directory watch, specifying options
Expand Down
12 changes: 10 additions & 2 deletions include/efsw/efsw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ enum Option {
/// For Windows, per default all events are captured but we might only be interested
/// in a subset; the value of the option should be set to a bitwise or'ed set of
/// FILE_NOTIFY_CHANGE_* flags.
WinNotifyFilter = 2
WinNotifyFilter = 2,
/// For macOS (FSEvents backend), per default all modified event types are capture but we might
// only be interested in a subset; the value of the option should be set to a set of bitwise
// from:
// kFSEventStreamEventFlagItemFinderInfoMod
// kFSEventStreamEventFlagItemModified
// kFSEventStreamEventFlagItemInodeMetaMod
// Default configuration will set the 3 flags
MacModifiedFilter = 3,
};
}
typedef Options::Option Option;
Expand Down Expand Up @@ -168,7 +176,7 @@ class EFSW_API FileWatcher {
/// @param recursive Set this to true to include subdirectories
/// @param options Allows customization of a watcher
/// @return Returns the watch id for the directory or, on error, a WatchID with Error type.
WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive,
WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive,
const std::vector<WatcherOption> &options );

/// Remove a directory watch. This is a brute force search O(nlogn).
Expand Down
Loading

0 comments on commit 1164bb9

Please sign in to comment.