Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Sep 3, 2024
2 parents 8d9db3c + 2f90a44 commit 7acb481
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 55 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ CMakeFiles/
*.dylib
*.lib
/.cache
/efsw-test
/efsw-test-stdc
31 changes: 11 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ if(APPLE)
src/efsw/WatcherFSEvents.cpp
src/efsw/WatcherKqueue.cpp
)

if(NOT CMAKE_SYSTEM_VERSION GREATER 9)
target_compile_definitions(efsw PRIVATE EFSW_FSEVENTS_NOT_SUPPORTED)
endif()
elseif(WIN32)
list(APPEND EFSW_CPP_SOURCE
src/efsw/FileWatcherWin32.cpp
Expand All @@ -113,7 +109,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
src/efsw/WatcherInotify.cpp
)

if(NOT EXISTS "/usr/include/sys/inotify.h" AND NOT EXISTS "/usr/local/include/sys/inotify.h")
find_path(EFSW_INOTIFY_H NAMES sys/inotify.h NO_CACHE)
if(EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND")
target_compile_definitions(efsw PRIVATE EFSW_INOTIFY_NOSYS)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
Expand All @@ -123,7 +120,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
)
endif()

if(MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
target_compile_definitions(efsw PRIVATE _SCL_SECURE_NO_WARNINGS)
else()
target_compile_options(efsw PRIVATE -Wall -Wno-long-long -fPIC)
Expand Down Expand Up @@ -160,7 +158,9 @@ configure_package_config_file(
)

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

if(EFSW_INSTALL)
install(TARGETS efsw EXPORT efswExport
Expand All @@ -175,25 +175,16 @@ if(EFSW_INSTALL)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/efsw
)

install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}Targets.cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")

if(BUILD_SHARED_LIBS)
if(BUILD_STATIC_LIBS)
install(TARGETS efsw-static EXPORT efswExport
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(
FILES
include/efsw/efsw.h include/efsw/efsw.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/efsw
)

install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}-staticTargets.cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")
endif()

install(EXPORT efswExport NAMESPACE efsw:: DESTINATION "${packageDestDir}" FILE ${PROJECT_NAME}Targets.cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/efswConfig.cmake DESTINATION "${packageDestDir}")
endif()

if(BUILD_TEST_APP)
Expand Down
3 changes: 3 additions & 0 deletions efswConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
@PACKAGE_INIT@

@DEPENDENCIES_SECTION@
include(CMakeFindDependencyMacro)

find_dependency(Threads)

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
6 changes: 4 additions & 2 deletions src/efsw/Debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ void efPRINTC( unsigned int cond, const char* format, ... );
#define efDEBUGC( cond, format, args... ) \
{}
#else
#define efDEBUG
#define efDEBUGC
#define efDEBUG( ... ) \
{}
#define efDEBUGC( ... ) \
{}
#endif

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/efsw/FileSystem.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstring>
#include <efsw/FileSystem.hpp>
#include <efsw/platform/platformimpl.hpp>
#include <cstring>

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

std::string result( maxSize, '\0' );
std::string result( maxSize + 1, '\0' );
if ( CFStringGetCString( cfMutable, &result[0], result.size(), kCFStringEncodingUTF8 ) ) {
result.resize( std::strlen( result.c_str() ) );
CFRelease( cfStringRef );
Expand Down
6 changes: 4 additions & 2 deletions src/efsw/FileWatcherWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ FileWatcherWin32::~FileWatcherWin32() {

removeAllWatches();

CloseHandle( mIOCP );
if ( mIOCP )
CloseHandle( mIOCP );
}

WatchID FileWatcherWin32::addWatch( const std::string& directory, FileWatchListener* watcher,
Expand Down Expand Up @@ -143,7 +144,8 @@ void FileWatcherWin32::run() {
break;
} else {
Lock lock( mWatchesLock );
WatchCallback( numOfBytes, ov );
if (mWatches.find( (WatcherStructWin32*)ov ) != mWatches.end())
WatchCallback( numOfBytes, ov );
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/efsw/FileWatcherWin32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <efsw/WatcherWin32.hpp>
#include <map>
#include <set>
#include <unordered_set>
#include <vector>

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

FileWatcherWin32( FileWatcher* parent );

Expand Down
3 changes: 2 additions & 1 deletion src/efsw/WatcherKqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ void WatcherKqueue::watch() {
bool needScan = false;

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

0 comments on commit 7acb481

Please sign in to comment.