Skip to content

Commit 7acb481

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 8d9db3c + 2f90a44 commit 7acb481

10 files changed

+194
-55
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ CMakeFiles/
1717
*.dylib
1818
*.lib
1919
/.cache
20+
/efsw-test
21+
/efsw-test-stdc

CMakeLists.txt

+11-20
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ if(APPLE)
9898
src/efsw/WatcherFSEvents.cpp
9999
src/efsw/WatcherKqueue.cpp
100100
)
101-
102-
if(NOT CMAKE_SYSTEM_VERSION GREATER 9)
103-
target_compile_definitions(efsw PRIVATE EFSW_FSEVENTS_NOT_SUPPORTED)
104-
endif()
105101
elseif(WIN32)
106102
list(APPEND EFSW_CPP_SOURCE
107103
src/efsw/FileWatcherWin32.cpp
@@ -113,7 +109,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
113109
src/efsw/WatcherInotify.cpp
114110
)
115111

116-
if(NOT EXISTS "/usr/include/sys/inotify.h" AND NOT EXISTS "/usr/local/include/sys/inotify.h")
112+
find_path(EFSW_INOTIFY_H NAMES sys/inotify.h NO_CACHE)
113+
if(EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND")
117114
target_compile_definitions(efsw PRIVATE EFSW_INOTIFY_NOSYS)
118115
endif()
119116
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
@@ -123,7 +120,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
123120
)
124121
endif()
125122

126-
if(MSVC)
123+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR
124+
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
127125
target_compile_definitions(efsw PRIVATE _SCL_SECURE_NO_WARNINGS)
128126
else()
129127
target_compile_options(efsw PRIVATE -Wall -Wno-long-long -fPIC)
@@ -160,7 +158,9 @@ configure_package_config_file(
160158
)
161159

162160
export(TARGETS efsw NAMESPACE efsw:: FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake)
163-
export(TARGETS efsw-static NAMESPACE efsw:: FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-staticTargets.cmake)
161+
if(BUILD_STATIC_LIBS)
162+
export(TARGETS efsw-static NAMESPACE efsw:: APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake)
163+
endif()
164164

165165
if(EFSW_INSTALL)
166166
install(TARGETS efsw EXPORT efswExport
@@ -175,25 +175,16 @@ if(EFSW_INSTALL)
175175
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/efsw
176176
)
177177

178-
install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}Targets.cmake)
179-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")
180-
181-
if(BUILD_SHARED_LIBS)
178+
if(BUILD_STATIC_LIBS)
182179
install(TARGETS efsw-static EXPORT efswExport
183180
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
184181
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
185182
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
186183
)
187-
188-
install(
189-
FILES
190-
include/efsw/efsw.h include/efsw/efsw.hpp
191-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/efsw
192-
)
193-
194-
install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}-staticTargets.cmake)
195-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")
196184
endif()
185+
186+
install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}Targets.cmake)
187+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")
197188
endif()
198189

199190
if(BUILD_TEST_APP)

efswConfig.cmake.in

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
@PACKAGE_INIT@
44

55
@DEPENDENCIES_SECTION@
6+
include(CMakeFindDependencyMacro)
7+
8+
find_dependency(Threads)
69

710
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

src/efsw/Debug.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ void efPRINTC( unsigned int cond, const char* format, ... );
4949
#define efDEBUGC( cond, format, args... ) \
5050
{}
5151
#else
52-
#define efDEBUG
53-
#define efDEBUGC
52+
#define efDEBUG( ... ) \
53+
{}
54+
#define efDEBUGC( ... ) \
55+
{}
5456
#endif
5557

5658
#endif

src/efsw/FileSystem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#include <cstring>
12
#include <efsw/FileSystem.hpp>
23
#include <efsw/platform/platformimpl.hpp>
3-
#include <cstring>
44

55
#if EFSW_OS == EFSW_OS_MACOSX
66
#include <CoreFoundation/CoreFoundation.h>
@@ -107,7 +107,7 @@ std::string FileSystem::precomposeFileName( const std::string& name ) {
107107
return std::string();
108108
}
109109

110-
std::string result( maxSize, '\0' );
110+
std::string result( maxSize + 1, '\0' );
111111
if ( CFStringGetCString( cfMutable, &result[0], result.size(), kCFStringEncodingUTF8 ) ) {
112112
result.resize( std::strlen( result.c_str() ) );
113113
CFRelease( cfStringRef );

src/efsw/FileWatcherWin32.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ FileWatcherWin32::~FileWatcherWin32() {
2626

2727
removeAllWatches();
2828

29-
CloseHandle( mIOCP );
29+
if ( mIOCP )
30+
CloseHandle( mIOCP );
3031
}
3132

3233
WatchID FileWatcherWin32::addWatch( const std::string& directory, FileWatchListener* watcher,
@@ -143,7 +144,8 @@ void FileWatcherWin32::run() {
143144
break;
144145
} else {
145146
Lock lock( mWatchesLock );
146-
WatchCallback( numOfBytes, ov );
147+
if (mWatches.find( (WatcherStructWin32*)ov ) != mWatches.end())
148+
WatchCallback( numOfBytes, ov );
147149
}
148150
}
149151
} else {

src/efsw/FileWatcherWin32.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <efsw/WatcherWin32.hpp>
99
#include <map>
10-
#include <set>
10+
#include <unordered_set>
1111
#include <vector>
1212

1313
namespace efsw {
@@ -17,7 +17,7 @@ namespace efsw {
1717
class FileWatcherWin32 : public FileWatcherImpl {
1818
public:
1919
/// type for a map from WatchID to WatcherWin32 pointer
20-
typedef std::set<WatcherStructWin32*> Watches;
20+
typedef std::unordered_set<WatcherStructWin32*> Watches;
2121

2222
FileWatcherWin32( FileWatcher* parent );
2323

src/efsw/WatcherKqueue.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ void WatcherKqueue::watch() {
354354
bool needScan = false;
355355

356356
// Then we get the the events of the current folder
357-
while ( ( nev = kevent( mKqueue, &mChangeList[0], mChangeListCount + 1, &event, 1,
357+
while ( !mChangeList.empty() &&
358+
( nev = kevent( mKqueue, mChangeList.data(), mChangeListCount + 1, &event, 1,
358359
&mWatcher->mTimeOut ) ) != 0 ) {
359360
// An error ocurred?
360361
if ( nev == -1 ) {

0 commit comments

Comments
 (0)