diff --git a/CHANGELOG.md b/CHANGELOG.md
index d110990eb6..2362db05cb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,12 @@
- some warnings detected by LGTM or VS fixed.
+- [#477](http://github.com/Nelson-numerical-software/nelson/issues/477): update files watcher using `efsw`.
+
## Bug Fixes:
- [#480](http://github.com/Nelson-numerical-software/nelson/issues/468): A(':') = [] was not managed.
-
# 0.5.7 (2021-07-24)
## Features:
diff --git a/CMake/MacOsConfig.cmake b/CMake/MacOsConfig.cmake
index 09158e468d..72d9431ace 100644
--- a/CMake/MacOsConfig.cmake
+++ b/CMake/MacOsConfig.cmake
@@ -29,6 +29,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_ARCHITECTURES "${ARCH}")
set(Boost_NO_SYSTEM_PATHS "TRUE")
set(MAC_FRAMEWORK_FOUNDATION_LIBRARY "-framework Foundation")
+ set(MAC_FRAMEWORK_CORESERVICES_LIBRARY "-framework CoreServices")
set(MAC_FRAMEWORK_APPKIT_LIBRARY "-framework AppKit")
set(MAC_LAPACKE_LIBRARY -lblas -llapack )
find_package (openblas REQUIRED)
diff --git a/THIRDPARTY.md b/THIRDPARTY.md
index 1dc64498af..fccd8bb4a9 100644
--- a/THIRDPARTY.md
+++ b/THIRDPARTY.md
@@ -96,13 +96,13 @@ Microsoft MPI (MS-MPI) is a Microsoft implementation of the Message Passing Inte
> https://www.open-mpi.org/community/license.php
-- SimpleFileWatcher
+- Entropia File System Watcher
a C++ wrapper for OS file monitoring systems
-> https://github.com/apetrone/simplefilewatcher
+> https://github.com/SpartanJ/efsw
-> https://github.com/apetrone/simplefilewatcher/blob/master/License.txt
+> https://github.com/SpartanJ/efsw/blob/master/LICENSE
- Libxml2
diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt
index 84c66be4c7..ed1c420f1d 100644
--- a/modules/core/CMakeLists.txt
+++ b/modules/core/CMakeLists.txt
@@ -38,7 +38,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../os_functions/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../nelson_manager/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../files_folders_functions/src/include
- ${CMAKE_CURRENT_SOURCE_DIR}/../i18n/src/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/../i18n/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../string/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../core/src/include/picoSHA2)
# ==============================================================================
diff --git a/modules/interpreter/CMakeLists.txt b/modules/interpreter/CMakeLists.txt
index 35d83880e2..b481c9e32d 100644
--- a/modules/interpreter/CMakeLists.txt
+++ b/modules/interpreter/CMakeLists.txt
@@ -31,7 +31,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/src/include
${CMAKE_CURRENT_SOURCE_DIR}/src/grammar
- ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/FileWatcher
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp
${CMAKE_CURRENT_SOURCE_DIR}/../nelson_manager/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../types/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../error_manager/src/include
@@ -46,7 +46,8 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../profiler/src/include)
# ==============================================================================
file(GLOB INTERPRETER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp"
- "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/FileWatcher/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/efsw/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/efsw/platform/posix/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/grammar/*.cpp")
# ==============================================================================
add_library(${module_library_name} SHARED ${INTERPRETER_SRC})
@@ -62,7 +63,9 @@ target_link_libraries(
nlsI18n
nlsOs_functions
nlsProfiler
- ${BOOST_LIBRARIES})
+ ${BOOST_LIBRARIES}
+ ${MAC_FRAMEWORK_FOUNDATION_LIBRARY}
+ ${MAC_FRAMEWORK_CORESERVICES_LIBRARY})
# ==============================================================================
set_target_properties(
${module_library_name}
diff --git a/modules/interpreter/src/c/nlsInterpreter.vcxproj b/modules/interpreter/src/c/nlsInterpreter.vcxproj
index d2989519dc..a90b3e7f48 100644
--- a/modules/interpreter/src/c/nlsInterpreter.vcxproj
+++ b/modules/interpreter/src/c/nlsInterpreter.vcxproj
@@ -94,7 +94,7 @@
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;_USRDLL;NLSINTERPRETER_EXPORTS;YY_NEVER_INTERACTIVE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp/FileWatcher;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
+ $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
4290;4251;4065
StreamingSIMDExtensions2
true
@@ -122,7 +122,7 @@
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;_USRDLL;NLSINTERPRETER_EXPORTS;YY_NEVER_INTERACTIVE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp/FileWatcher;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
+ $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
4290;4251;4065
NotSet
true
@@ -152,7 +152,7 @@
true
true
WIN32;NDEBUG;_WINDOWS;_USRDLL;NLSINTERPRETER_EXPORTS;YY_NEVER_INTERACTIVE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp/FileWatcher;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
+ $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
4290;4251;4065
StreamingSIMDExtensions2
false
@@ -186,7 +186,7 @@
true
true
WIN32;NDEBUG;_WINDOWS;_USRDLL;NLSINTERPRETER_EXPORTS;YY_NEVER_INTERACTIVE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp/FileWatcher;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
+ $(SolutionDir)modules/engine/src/include;$(SolutionDir)modules/nelson_manager/src/include;$(SolutionDir)modules/overload/src/include;$(SolutionDir)modules/characters_encoding/src/include;$(SolutionDir)modules/mex/src/include;$(SolutionDir)modules/i18n/src/include;$(SolutionDir)modules/profiler/src/include;$(SolutionDir)modules/types/src/include;$(SolutionDir)modules/os_functions/src/include;$(SolutionDir)modules/operators/src/include;$(SolutionDir)modules/stream_manager/src/include;$(SolutionDir)modules/error_manager/src/include;$(SolutionDir)modules/terminal/src/include;$(SolutionDir)modules/interpreter/src/include;$(SolutionDir)modules/dynamic_link/src/include;$(SolutionDir)modules/interpreter/src/cpp;$(SolutionDir)modules/interpreter/src/grammar;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Boost;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/Eigen;$(SolutionDir)../NelSon-thirdparty-$(PlatformName)/mkl/include
4290;4251;4065
NotSet
false
@@ -228,6 +228,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -240,8 +261,6 @@
-
-
diff --git a/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters b/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters
index d4339476de..e8fd4cef6f 100644
--- a/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters
+++ b/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters
@@ -49,9 +49,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -133,12 +130,6 @@
Source Files
-
- Source Files
-
-
- Source Files
-
Source Files
@@ -196,6 +187,72 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
diff --git a/modules/interpreter/src/cpp/Evaluator.cpp b/modules/interpreter/src/cpp/Evaluator.cpp
index 0472ae1d56..50387e4588 100644
--- a/modules/interpreter/src/cpp/Evaluator.cpp
+++ b/modules/interpreter/src/cpp/Evaluator.cpp
@@ -4197,7 +4197,6 @@ Evaluator::evalCLI()
{
while (1) {
if (!bpActive) {
- FileWatcherManager::getInstance()->update();
clearStacks();
}
std::wstring commandLine;
diff --git a/modules/interpreter/src/cpp/FileWatcher/FileWatcher.cpp b/modules/interpreter/src/cpp/FileWatcher/FileWatcher.cpp
deleted file mode 100644
index 9d2acfcc6f..0000000000
--- a/modules/interpreter/src/cpp/FileWatcher/FileWatcher.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- Copyright (c) 2009 James Wynn (james@jameswynn.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "FileWatcher.h"
-#include
-
-#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
-# include
-# define FILEWATCHER_IMPL FileWatcherWin32
-#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_KQUEUE
-# include
-# define FILEWATCHER_IMPL FileWatcherOSX
-#elif FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
-# include
-# define FILEWATCHER_IMPL FileWatcherLinux
-#endif
-
-namespace FW {
-
- //--------
- FileWatcher::FileWatcher()
- {
- mImpl = new FILEWATCHER_IMPL();
- }
-
- //--------
- FileWatcher::~FileWatcher()
- {
- delete mImpl;
- mImpl = nullptr;
- }
-
- //--------
- WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher)
- {
- return mImpl->addWatch(directory, watcher, false);
- }
-
- //--------
- WatchID FileWatcher::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
- {
- return mImpl->addWatch(directory, watcher, recursive);
- }
-
- //--------
- void FileWatcher::removeWatch(const String& directory)
- {
- mImpl->removeWatch(directory);
- }
-
- //--------
- void FileWatcher::removeWatch(WatchID watchid)
- {
- mImpl->removeWatch(watchid);
- }
-
- //--------
- void FileWatcher::update()
- {
- mImpl->update();
- }
-
-};//namespace FW
diff --git a/modules/interpreter/src/cpp/FileWatcher/FileWatcher.h b/modules/interpreter/src/cpp/FileWatcher/FileWatcher.h
deleted file mode 100644
index bdffc19d72..0000000000
--- a/modules/interpreter/src/cpp/FileWatcher/FileWatcher.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- Main header for the FileWatcher class. Declares all implementation
- classes to reduce compilation overhead.
-
- @author James Wynn
- @date 4/15/2009
-
- Copyright (c) 2009 James Wynn (james@jameswynn.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#ifndef _FW_FILEWATCHER_H_
-#define _FW_FILEWATCHER_H_
-#pragma once
-
-#include
-#include
-#include "characters_encoding.hpp"
-
-#define WatchID unsigned long
-
-namespace FW {
- /// Type for a string
-#ifdef _MSC_VER
- using String = std::wstring;
-#else
- typedef std::string String;
-#endif
-
- // forward declarations
- class FileWatcherImpl;
- class FileWatchListener;
-
- /// Base exception class
- /// @class Exception
- class FWException : public std::runtime_error {
- public:
-#ifdef _MSC_VER
- FWException(const String& message)
- : std::runtime_error(Nelson::wstring_to_utf8(message))
-#else
- FWException(const String& message)
- : std::runtime_error(message)
-#endif
- {}
- };
-
- /// Exception thrown when a file is not found.
- /// @class FileNotFoundException
- class FileNotFoundException : public FWException {
- public:
-#ifdef _MSC_VER
- FileNotFoundException()
- : FWException(L"File not found")
-#else
- FileNotFoundException()
- : FWException("File not found")
-#endif
- {}
-
-#ifdef _MSC_VER
- FileNotFoundException(const String& filename)
- : FWException(L"File not found (" + filename + L")")
-#else
- FileNotFoundException(const String& filename)
- : FWException("File not found (" + filename + ")")
-#endif
- {}
-
- };
-
- /// Actions to listen for. Rename will send two events, one for
- /// the deletion of the old file, and one for the creation of the
- /// new file.
- namespace Actions {
- enum Action
- {
- /// Sent when a file is created or renamed
- Add = 1,
- /// Sent when a file is deleted or renamed
- Delete = 2,
- /// Sent when a file is modified
- Modified = 4
- };
- } // namespace Actions
- using Action = Actions::Action;
-
- /// Listens to files and directories and dispatches events
- /// to notify the parent program of the changes.
- /// @class FileWatcher
- class FileWatcher {
- public:
- ///
- ///
- FileWatcher();
-
- ///
- ///
- virtual ~FileWatcher();
-
- /// Add a directory watch. Same as the other addWatch, but doesn't have recursive option.
- /// For backwards compatibility.
- /// @exception FileNotFoundException Thrown when the requested directory does not exist
- WatchID addWatch(const String& directory, FileWatchListener* watcher);
-
- /// Add a directory watch
- /// @exception FileNotFoundException Thrown when the requested directory does not exist
- WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive);
-
- /// Remove a directory watch. This is a brute force search O(nlogn).
- void removeWatch(const String& directory);
-
- /// Remove a directory watch. This is a map lookup O(logn).
- void removeWatch(WatchID watchid);
-
- /// Updates the watcher. Must be called often.
- void update();
-
- private:
- /// The implementation
- FileWatcherImpl* mImpl;
-
- };//end FileWatcher
-
-
- /// Basic interface for listening for file events.
- /// @class FileWatchListener
- class FileWatchListener {
- public:
- FileWatchListener() = default;
- virtual ~FileWatchListener() = default;
-
- /// Handles the action file action
- /// @param watchid The watch id for the directory
- /// @param dir The directory
- /// @param filename The filename that was accessed (not full path)
- /// @param action Action that was performed
- virtual void handleFileAction(WatchID watchid, const String& dir, const String& filename, Action action) = 0;
-
- };//class FileWatchListener
-
-};//namespace FW
-
-#endif//_FW_FILEWATCHER_H_
diff --git a/modules/interpreter/src/cpp/FileWatcher/FileWatcherImpl.h b/modules/interpreter/src/cpp/FileWatcher/FileWatcherImpl.h
deleted file mode 100644
index 315f9ebdaa..0000000000
--- a/modules/interpreter/src/cpp/FileWatcher/FileWatcherImpl.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- Basic interface for the FileWatcher backend.
-
- @author James Wynn
- @date 5/11/2009
-
- Copyright (c) 2009 James Wynn (james@jameswynn.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-#ifndef _FW_FILEWATCHERIMPL_H_
-#define _FW_FILEWATCHERIMPL_H_
-#pragma once
-
-#include "FileWatcher.h"
-
-#define FILEWATCHER_PLATFORM_WIN32 1
-#define FILEWATCHER_PLATFORM_LINUX 2
-#define FILEWATCHER_PLATFORM_KQUEUE 3
-
-#if defined(_WIN32)
-# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_WIN32
-#elif defined(__APPLE_CC__) || defined(BSD)
-# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_KQUEUE
-#elif defined(__linux__)
-# define FILEWATCHER_PLATFORM FILEWATCHER_PLATFORM_LINUX
-#endif
-
-namespace FW {
- struct WatchStruct;
-
- class FileWatcherImpl {
- public:
- ///
- ///
- FileWatcherImpl() = default;
-
- ///
- ///
- virtual ~FileWatcherImpl() = default;
-
- /// Add a directory watch
- /// @exception FileNotFoundException Thrown when the requested directory does not exist
- virtual WatchID addWatch(const String& directory, FileWatchListener* watcher, bool recursive) = 0;
-
- /// Remove a directory watch. This is a brute force lazy search O(nlogn).
- virtual void removeWatch(const String& directory) = 0;
-
- /// Remove a directory watch. This is a map lookup O(logn).
- virtual void removeWatch(WatchID watchid) = 0;
-
- /// Updates the watcher. Must be called often.
- virtual void update() = 0;
-
- /// Handles the action
- virtual void handleAction(WatchStruct* watch, const String& filename, unsigned long action) = 0;
-
- };//end FileWatcherImpl
-};//namespace FW
-
-#endif//_FW_FILEWATCHERIMPL_H_
diff --git a/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.cpp b/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.cpp
deleted file mode 100644
index c9075cd0dd..0000000000
--- a/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- Copyright (c) 2009 James Wynn (james@jameswynn.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-
- James Wynn james@jameswynn.com
-*/
-
-#include
-
-#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "Exception.hpp"
-
-#define BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024)
-
-namespace FW {
-
- struct WatchStruct
- {
- WatchID mWatchID;
- String mDirName;
- FileWatchListener* mListener;
- };
-
- //--------
- FileWatcherLinux::FileWatcherLinux()
- {
- mFD = inotify_init();
- if (mFD < 0)
- {
- fprintf (stderr, "Error: %s\n", strerror(errno));
- }
- mTimeOut.tv_sec = 0;
- mTimeOut.tv_usec = 0;
- FD_ZERO(&mDescriptorSet);
- }
-
- //--------
- FileWatcherLinux::~FileWatcherLinux()
- {
- WatchMap::iterator iter = mWatches.begin();
- WatchMap::iterator end = mWatches.end();
- for(; iter != end; ++iter)
- {
- delete iter->second;
- }
- mWatches.clear();
- }
-
- //--------
- WatchID FileWatcherLinux::addWatch(const String& directory, FileWatchListener* watcher, bool recursive)
- {
- int wd = inotify_add_watch (mFD, directory.c_str(),
- IN_CLOSE_WRITE | IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE);
- if (wd < 0)
- {
- if(errno == ENOENT)
- {
- throw FileNotFoundException(directory);
- }
- else
- {
- throw Nelson::Exception(strerror(errno));
- }
- // fprintf (stderr, "Error: %s\n", strerror(errno));
- // return -1;
- }
- WatchStruct* pWatch = new WatchStruct();
- pWatch->mListener = watcher;
- pWatch->mWatchID = wd;
- pWatch->mDirName = directory;
- mWatches.insert(std::make_pair(wd, pWatch));
- return wd;
- }
-
- //--------
- void FileWatcherLinux::removeWatch(const String& directory)
- {
- WatchMap::iterator iter = mWatches.begin();
- WatchMap::iterator end = mWatches.end();
- for(; iter != end; ++iter)
- {
- if(directory == iter->second->mDirName)
- {
- removeWatch(iter->first);
- return;
- }
- }
- }
-
- //--------
- void FileWatcherLinux::removeWatch(WatchID watchid)
- {
- WatchMap::iterator iter = mWatches.find(watchid);
- if(iter == mWatches.end())
- {
- return;
- }
- WatchStruct* watch = iter->second;
- mWatches.erase(iter);
- inotify_rm_watch(mFD, watchid);
- delete watch;
- watch = 0;
- }
-
- //--------
- void FileWatcherLinux::update()
- {
- FD_SET(mFD, &mDescriptorSet);
- int ret = select(mFD + 1, &mDescriptorSet, NULL, NULL, &mTimeOut);
- if(ret < 0)
- {
- perror("select");
- }
- else if(FD_ISSET(mFD, &mDescriptorSet))
- {
- ssize_t len, i = 0;
- char action[81+FILENAME_MAX] = {0};
- char buff[BUFF_SIZE] = {0};
- len = read (mFD, buff, BUFF_SIZE);
- while (i < len)
- {
- struct inotify_event *pevent = (struct inotify_event *)&buff[i];
- WatchStruct* watch = mWatches[pevent->wd];
- handleAction(watch, pevent->name, pevent->mask);
- i += sizeof(struct inotify_event) + pevent->len;
- }
- }
- }
-
- //--------
- void FileWatcherLinux::handleAction(WatchStruct* watch, const String& filename, unsigned long action)
- {
- if(!watch->mListener)
- {
- return;
- }
- if(IN_CLOSE_WRITE & action)
- {
- watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
- Actions::Modified);
- }
- if(IN_MOVED_TO & action || IN_CREATE & action)
- {
- watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
- Actions::Add);
- }
- if(IN_MOVED_FROM & action || IN_DELETE & action)
- {
- watch->mListener->handleFileAction(watch->mWatchID, watch->mDirName, filename,
- Actions::Delete);
- }
- }
-
-};//namespace FW
-
-#endif//FILEWATCHER_PLATFORM_LINUX
diff --git a/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.h b/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.h
deleted file mode 100644
index 98ed5752b5..0000000000
--- a/modules/interpreter/src/cpp/FileWatcher/FileWatcherLinux.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- Implementation header file for Linux based on inotify.
-
- @author James Wynn
- @date 4/15/2009
-
- Copyright (c) 2009 James Wynn (james@jameswynn.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-#ifndef _FW_FILEWATCHERLINUX_H_
-#define _FW_FILEWATCHERLINUX_H_
-#pragma once
-
-#include "FileWatcherImpl.h"
-
-#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_LINUX
-
-#include