Skip to content

Commit 8583456

Browse files
committed
Dep/efsw: Update to SpartanJ/efsw@36c1c70
(cherry picked from commit 937e61853319ac0e5b29f0bcbe5390a71cb7625f)
1 parent 51c6f71 commit 8583456

78 files changed

Lines changed: 4670 additions & 5291 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dep/PackageList.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ bzip2 (a freely available, patent free, high-quality data compressor)
1212
http://www.bzip.org/
1313
Version: 1.0.6
1414

15-
efws (Entropia File System Watcher - crossplatform file system watcher)
16-
https://bitbucket.org/SpartanJ/efsw
17-
Version: 1.0.0 e6afbec564e249771046c714b0c7f2154e4c7fef
15+
efsw (Entropia File System Watcher - crossplatform file system watcher)
16+
https://github.com/SpartanJ/efsw
17+
Version: 1.3.1+ 36c1c7004a34b6f40719f0830bcfb10325415451
1818

1919
fmt (a small, safe and fast formatting library)
2020
https://github.com/fmtlib/fmt

dep/efsw/.hg_archival.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

dep/efsw/CMakeLists.txt

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,108 @@
1-
set(SRCS
1+
set(EFSW_CPP_SOURCE
2+
src/efsw/Atomic.hpp
3+
src/efsw/base.hpp
24
src/efsw/Debug.cpp
5+
src/efsw/Debug.hpp
36
src/efsw/DirectorySnapshot.cpp
7+
src/efsw/DirectorySnapshot.hpp
48
src/efsw/DirectorySnapshotDiff.cpp
9+
src/efsw/DirectorySnapshotDiff.hpp
510
src/efsw/DirWatcherGeneric.cpp
11+
src/efsw/DirWatcherGeneric.hpp
612
src/efsw/FileInfo.cpp
13+
src/efsw/FileInfo.hpp
714
src/efsw/FileSystem.cpp
15+
src/efsw/FileSystem.hpp
816
src/efsw/FileWatcher.cpp
917
src/efsw/FileWatcherCWrapper.cpp
1018
src/efsw/FileWatcherGeneric.cpp
19+
src/efsw/FileWatcherGeneric.hpp
1120
src/efsw/FileWatcherImpl.cpp
21+
src/efsw/FileWatcherImpl.hpp
22+
src/efsw/Lock.hpp
1223
src/efsw/Log.cpp
1324
src/efsw/Mutex.cpp
25+
src/efsw/Mutex.hpp
26+
src/efsw/sophist.h
1427
src/efsw/String.cpp
28+
src/efsw/String.hpp
1529
src/efsw/System.cpp
30+
src/efsw/System.hpp
1631
src/efsw/Thread.cpp
32+
src/efsw/Thread.hpp
33+
src/efsw/Utf.hpp
1734
src/efsw/Watcher.cpp
18-
src/efsw/WatcherGeneric.cpp)
35+
src/efsw/Watcher.hpp
36+
src/efsw/WatcherGeneric.cpp
37+
src/efsw/WatcherGeneric.hpp
38+
src/efsw/platform/platformimpl.hpp
39+
)
1940

2041
if (WIN32)
21-
list (APPEND SRCS
42+
list (APPEND EFSW_CPP_SOURCE
2243
src/efsw/platform/win/FileSystemImpl.cpp
44+
src/efsw/platform/win/FileSystemImpl.hpp
2345
src/efsw/platform/win/MutexImpl.cpp
46+
src/efsw/platform/win/MutexImpl.hpp
2447
src/efsw/platform/win/SystemImpl.cpp
25-
src/efsw/platform/win/ThreadImpl.cpp)
48+
src/efsw/platform/win/SystemImpl.hpp
49+
src/efsw/platform/win/ThreadImpl.cpp
50+
src/efsw/platform/win/ThreadImpl.hpp)
2651
else ()
27-
list (APPEND SRCS
52+
list (APPEND EFSW_CPP_SOURCE
2853
src/efsw/platform/posix/FileSystemImpl.cpp
54+
src/efsw/platform/posix/FileSystemImpl.hpp
2955
src/efsw/platform/posix/MutexImpl.cpp
56+
src/efsw/platform/posix/MutexImpl.hpp
3057
src/efsw/platform/posix/SystemImpl.cpp
31-
src/efsw/platform/posix/ThreadImpl.cpp)
58+
src/efsw/platform/posix/SystemImpl.hpp
59+
src/efsw/platform/posix/ThreadImpl.cpp
60+
src/efsw/platform/posix/ThreadImpl.hpp)
3261
endif()
3362

3463
if (APPLE)
35-
list (APPEND SRCS
64+
list (APPEND EFSW_CPP_SOURCE
3665
src/efsw/FileWatcherFSEvents.cpp
66+
src/efsw/FileWatcherFSEvents.hpp
3767
src/efsw/FileWatcherKqueue.cpp
68+
src/efsw/FileWatcherKqueue.hpp
3869
src/efsw/WatcherFSEvents.cpp
39-
src/efsw/WatcherKqueue.cpp)
40-
41-
exec_program(uname ARGS -v OUTPUT_VARIABLE OSX_VERSION)
42-
string(REGEX MATCH "[0-9]+" OSX_VERSION ${OSX_VERSION})
43-
if (NOT OSX_VERSION GREATER 9)
44-
set(OPTIONAL_COMPILE_DEFINITIONS "-DEFSW_FSEVENTS_NOT_SUPPORTED")
45-
endif()
70+
src/efsw/WatcherFSEvents.hpp
71+
src/efsw/WatcherKqueue.cpp
72+
src/efsw/WatcherKqueue.hpp)
4673
set(OPTIONAL_LINK_LIBRARIES "-framework CoreFoundation" "-framework CoreServices")
4774
elseif (WIN32)
48-
list (APPEND SRCS
75+
list (APPEND EFSW_CPP_SOURCE
4976
src/efsw/FileWatcherWin32.cpp
50-
src/efsw/WatcherWin32.cpp)
77+
src/efsw/FileWatcherWin32.hpp
78+
src/efsw/WatcherWin32.cpp
79+
src/efsw/WatcherWin32.hpp)
5180
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
52-
list (APPEND SRCS
81+
list (APPEND EFSW_CPP_SOURCE
5382
src/efsw/FileWatcherInotify.cpp
54-
src/efsw/WatcherInotify.cpp)
55-
if (NOT EXISTS "/usr/include/sys/inotify.h" AND NOT EXISTS "/usr/local/include/sys/inotify.h")
83+
src/efsw/FileWatcherInotify.hpp
84+
src/efsw/WatcherInotify.cpp
85+
src/efsw/WatcherInotify.hpp)
86+
find_path(EFSW_INOTIFY_H
87+
NAMES
88+
sys/inotify.h
89+
NO_CACHE
90+
)
91+
if (EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND")
92+
list (APPEND EFSW_CPP_SOURCE
93+
src/efsw/inotify-nosys.h
94+
)
5695
set(OPTIONAL_COMPILE_DEFINITIONS "-DEFSW_INOTIFY_NOSYS")
5796
endif()
5897
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
59-
list (APPEND SRCS
98+
list (APPEND EFSW_CPP_SOURCE
6099
src/efsw/FileWatcherKqueue.cpp
61-
src/efsw/WatcherKqueue.cpp)
100+
src/efsw/FileWatcherKqueue.hpp
101+
src/efsw/WatcherKqueue.cpp
102+
src/efsw/WatcherKqueue.hpp)
62103
endif()
63104

64-
add_library(efsw STATIC ${SRCS})
105+
add_library(efsw STATIC ${EFSW_CPP_SOURCE})
65106

66107
target_include_directories(efsw
67108
PUBLIC

dep/efsw/LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012 Martín Lucas Golini
1+
Copyright (c) 2020 Martín Lucas Golini
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
THE SOFTWARE.
2020

2121
This software is a fork of the "simplefilewatcher" by James Wynn (james@jameswynn.com)
22-
http://code.google.com/p/simplefilewatcher/ also MIT licensed.
22+
http://code.google.com/p/simplefilewatcher/ also MIT licensed.

dep/efsw/README.md

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
Entropia File System Watcher
1+
Entropia File System Watcher ![efsw](https://web.ensoft.dev/efsw/efsw-logo.svg)
22
============================
3+
4+
[![build status](https://img.shields.io/github/actions/workflow/status/SpartanJ/efsw/main.yml?branch=master)](https://github.com/SpartanJ/efsw/actions?query=workflow%3Abuild)
5+
36
**efsw** is a C++ cross-platform file system watcher and notifier.
47

58
**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
1922
* OS-independent generic watcher
2023
(polling the disk for directory snapshots and comparing them periodically)
2124

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`.
2427

2528
**Code License**
2629
--------------
@@ -31,39 +34,41 @@ This should never happen, except for the Kqueue implementation, see `Platform li
3134

3235
```c++
3336
// Inherits from the abstract listener class, and implements the the file action handler
34-
class UpdateListener : public efsw::FileWatchListener
35-
{
36-
public:
37-
UpdateListener() {}
38-
39-
void handleFileAction( efsw::WatchID watchid, const std::string& dir, const std::string& filename, efsw::Action action, std::string oldFilename = "" )
40-
{
41-
switch( action )
42-
{
43-
case efsw::Actions::Add:
44-
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Added" << std::endl;
45-
break;
46-
case efsw::Actions::Delete:
47-
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Delete" << std::endl;
48-
break;
49-
case efsw::Actions::Modified:
50-
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Modified" << std::endl;
51-
break;
52-
case efsw::Actions::Moved:
53-
std::cout << "DIR (" << dir << ") FILE (" << filename << ") has event Moved from (" << oldFilename << ")" << std::endl;
54-
break;
55-
default:
56-
std::cout << "Should never happen!" << std::endl;
57-
}
58-
}
37+
class UpdateListener : public efsw::FileWatchListener {
38+
public:
39+
void handleFileAction( efsw::WatchID watchid, const std::string& dir,
40+
const std::string& filename, efsw::Action action,
41+
std::string oldFilename ) override {
42+
switch ( action ) {
43+
case efsw::Actions::Add:
44+
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+
}
5963
};
6064

6165
// 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();
6469

6570
// Create the instance of your efsw::FileWatcherListener implementation
66-
UpdateListener * listener = new UpdateListener();
71+
UpdateListener* listener = new UpdateListener();
6772

6873
// Add a folder to watch, and get the efsw::WatchID
6974
// It will watch the /tmp folder recursively ( the third parameter indicates that is recursive )
@@ -73,11 +78,16 @@ efsw::WatchID watchID = fileWatcher->addWatch( "/tmp", listener, true );
7378
// Adds another directory to watch. This time as non-recursive.
7479
efsw::WatchID watchID2 = fileWatcher->addWatch( "/usr", listener, false );
7580

81+
// For Windows, adds another watch, specifying to use a bigger buffer, to not miss events
82+
// (do not use for network locations, see efsw.hpp for details).
83+
efsw::WatchID watchID3 = fileWatcher->addWatch( "c:\\temp", listener, true, { (BufferSize, 128*1024) } );
84+
7685
// Start watching asynchronously the directories
7786
fileWatcher->watch();
7887

7988
// Remove the second watcher added
80-
// 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 )
8191
fileWatcher->removeWatch( watchID2 );
8292
```
8393
@@ -87,21 +97,21 @@ None :)
8797
8898
**Compiling**
8999
------------
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)
91101
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:
93103
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 ).
95105
96-
or
106+
or
97107
98-
`premake4 vs2010` to generate Visual Studio 2010 project.
108+
`premake5 vs2022` to generate Visual Studio 2022 project.
99109
100110
or
101111
102-
`premake4 xcode4` to generate Xcode 4 project.
112+
`premake5 xcode4` to generate Xcode 4 project.
103113
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).
105115
106116
**Platform limitations and clarifications**
107117
-------------------------------------------
@@ -112,21 +122,21 @@ handleFileAction returns UTF-8 strings in all platforms.
112122
113123
Windows and FSEvents Mac OS X implementation can't follow symlinks ( it will ignore followSymlinks() and allowOutOfScopeLinks() ).
114124
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.
116126
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.
118128
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.
120130
121131
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 ).
122132
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.
124134
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.
126136
127137
**Useful information**
128138
--------------------
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).
130140
131141
There's a string manipulation class not exposed in the efsw header ( efsw::String ) that can be used to make string encoding conversion.
132142

dep/efsw/include/efsw/efsw.h

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,22 @@ enum efsw_error
8080
EFSW_OUTOFSCOPE = -3,
8181
EFSW_NOTREADABLE = -4,
8282
EFSW_REMOTE = -5,
83-
EFSW_UNSPECIFIED = -6
83+
EFSW_WATCHER_FAILED = -6,
84+
EFSW_UNSPECIFIED = -7
85+
};
86+
87+
enum efsw_option
88+
{
89+
/// For Windows, the default buffer size of 63*1024 bytes sometimes is not enough and
90+
/// file system events may be dropped. For that, using a different (bigger) buffer size
91+
/// can be defined here, but note that this does not work for network drives,
92+
/// because a buffer larger than 64K will fail the folder being watched, see
93+
/// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365465(v=vs.85).aspx)
94+
EFSW_OPT_WIN_BUFFER_SIZE = 1,
95+
/// For Windows, per default all events are captured but we might only be interested
96+
/// in a subset; the value of the option should be set to a bitwise or'ed set of
97+
/// FILE_NOTIFY_CHANGE_* flags.
98+
EFSW_OPT_WIN_NOTIFY_FILTER = 2
8499
};
85100

86101
/// Basic interface for listening for file events.
@@ -94,6 +109,11 @@ typedef void (*efsw_pfn_fileaction_callback) (
94109
void* param
95110
);
96111

112+
typedef struct {
113+
enum efsw_option option;
114+
int value;
115+
} efsw_watcher_option;
116+
97117
/**
98118
* Creates a new file-watcher
99119
* @param generic_mode Force the use of the Generic file watcher
@@ -103,15 +123,24 @@ efsw_watcher EFSW_API efsw_create(int generic_mode);
103123
/// Release the file-watcher and unwatch any directories
104124
void EFSW_API efsw_release(efsw_watcher watcher);
105125

106-
/// Retreive last error occured by file-watcher
126+
/// Retrieve last error occured by file-watcher
107127
EFSW_API const char* efsw_getlasterror();
108128

109-
/// Add a directory watch. Same as the other addWatch, but doesn't have recursive option.
110-
/// For backwards compatibility.
129+
/// Reset file-watcher last error
130+
EFSW_API void efsw_clearlasterror();
131+
132+
/// Add a directory watch
111133
/// On error returns WatchID with Error type.
112134
efsw_watchid EFSW_API efsw_addwatch(efsw_watcher watcher, const char* directory,
113135
efsw_pfn_fileaction_callback callback_fn, int recursive, void* param);
114136

137+
/// Add a directory watch, specifying options
138+
/// @param options Pointer to an array of watcher options
139+
/// @param nr_options Number of options referenced by \p options
140+
efsw_watchid EFSW_API efsw_addwatch_withoptions(efsw_watcher watcher, const char* directory,
141+
efsw_pfn_fileaction_callback callback_fn, int recursive, efsw_watcher_option *options,
142+
int options_number, void* param);
143+
115144
/// Remove a directory watch. This is a brute force search O(nlogn).
116145
void EFSW_API efsw_removewatch(efsw_watcher watcher, const char* directory);
117146

0 commit comments

Comments
 (0)