diff --git a/CHANGELOG.md b/CHANGELOG.md
index d110990eb6..566990ba70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,14 @@
- some warnings detected by LGTM or VS fixed.
+- [#477](http://github.com/Nelson-numerical-software/nelson/issues/477): update files watcher using `efsw`.
+
+- filename and line of last error available in test_run report.
+
## 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/f2c/etc/startup.m b/modules/f2c/etc/startup.m
index 6545b4bfcb..7e284c3505 100644
--- a/modules/f2c/etc/startup.m
+++ b/modules/f2c/etc/startup.m
@@ -24,5 +24,5 @@
% LICENCE_BLOCK_END
%=============================================================================
%addgateway(modulepath(nelsonroot(), 'f2c', 'builtin'));
-addpath(modulepath(nelsonroot(), 'f2c', 'functions'))
+addpath(modulepath(nelsonroot(), 'f2c', 'functions'), '-frozen')
%=============================================================================
diff --git a/modules/file_archiver/tests/test_unzip.m b/modules/file_archiver/tests/test_unzip_1.m
similarity index 100%
rename from modules/file_archiver/tests/test_unzip.m
rename to modules/file_archiver/tests/test_unzip_1.m
index e027e2478e..273d7c9257 100644
--- a/modules/file_archiver/tests/test_unzip.m
+++ b/modules/file_archiver/tests/test_unzip_1.m
@@ -34,7 +34,6 @@
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
-R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip']);
REF = { [temp_dest, '/test_zip/'], ...
[temp_dest, '/test_zip/dir_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
@@ -49,6 +48,7 @@
[temp_dest, '/test_zip/file_2.txt'], ...
[temp_dest, '/file_0.txt'], ...
[temp_dest, '/test_zip/1汉字2.PNG']};
+R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip']);
assert_isequal(R, REF);
for r = R
rr = r{1};
@@ -64,7 +64,6 @@
rmdir(temp_dest, 's');
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
-R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
REF = { [temp_dest, '/test_zip/'], ...
[temp_dest, '/test_zip/dir_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
@@ -79,6 +78,7 @@
[temp_dest, '/test_zip/file_2.txt'], ...
[temp_dest, '/file_0.txt'], ...
[temp_dest, '/test_zip/1汉字2.PNG']};
+R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
assert_isequal(R, REF);
%=============================================================================
for r = R
diff --git a/modules/file_archiver/tests/test_unzip_2.m b/modules/file_archiver/tests/test_unzip_2.m
new file mode 100644
index 0000000000..cd89af0126
--- /dev/null
+++ b/modules/file_archiver/tests/test_unzip_2.m
@@ -0,0 +1,61 @@
+%=============================================================================
+% Copyright (c) 2016-present Allan CORNET (Nelson)
+%=============================================================================
+% This file is part of the Nelson.
+%=============================================================================
+% LICENCE_BLOCK_BEGIN
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU Lesser General Public
+% License as published by the Free Software Foundation; either
+% version 2.1 of the License, or (at your option) any later version.
+%
+% Alternatively, you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU Lesser General Public License for more details.
+%
+% You should have received a copy of the GNU Lesser General Public
+% License along with this program. If not, see .
+% LICENCE_BLOCK_END
+%=============================================================================
+TMPDIR = tempdir();
+if ismac()
+ TMPDIR = ['/private', TMPDIR];
+end
+%=============================================================================
+temp_dest = [TMPDIR, createGUID()];
+R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
+REF = { [temp_dest, '/test_zip/'], ...
+ [temp_dest, '/test_zip/dir_1/'], ...
+ [temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
+ [temp_dest, '/test_zip/dir_1/dir_1_1/file_1_1_1.txt'], ...
+ [temp_dest, '/test_zip/dir_1/dir_1_1/file_1_1_2.txt'], ...
+ [temp_dest, '/test_zip/dir_1/dir_1_2/'], ...
+ [temp_dest, '/test_zip/dir_1/file_1_1.txt'], ...
+ [temp_dest, '/test_zip/dir_1/file_1_2.txt'], ...
+ [temp_dest, '/test_zip/dir_2/'], ...
+ [temp_dest, '/test_zip/dir_2/file_2_1.txt'], ...
+ [temp_dest, '/test_zip/file_1.txt'], ...
+ [temp_dest, '/test_zip/file_2.txt'], ...
+ [temp_dest, '/file_0.txt'], ...
+ [temp_dest, '/test_zip/1汉字2.PNG']};
+ assert_isequal(R, REF);
+ %=============================================================================
+for r = R
+ rr = r{1};
+ if endsWith(rr, '/')
+ assert_istrue(isdir(rr));
+ else
+ assert_istrue(isfile(rr));
+ fileinfo = dir(rr);
+ assert_istrue(fileinfo.bytes > 0);
+ end
+end
+cd(tempdir());
+rmdir(temp_dest, 's');
+%=============================================================================
diff --git a/modules/file_archiver/tests/test_zip_1.m b/modules/file_archiver/tests/test_zip_1.m
new file mode 100644
index 0000000000..fc32f1fbb0
--- /dev/null
+++ b/modules/file_archiver/tests/test_zip_1.m
@@ -0,0 +1,67 @@
+%=============================================================================
+% Copyright (c) 2016-present Allan CORNET (Nelson)
+%=============================================================================
+% This file is part of the Nelson.
+%=============================================================================
+% LICENCE_BLOCK_BEGIN
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU Lesser General Public
+% License as published by the Free Software Foundation; either
+% version 2.1 of the License, or (at your option) any later version.
+%
+% Alternatively, you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU Lesser General Public License for more details.
+%
+% You should have received a copy of the GNU Lesser General Public
+% License along with this program. If not, see .
+% LICENCE_BLOCK_END
+%=============================================================================
+assert_isequal(nargin('zip'), -3);
+assert_isequal(nargout('zip'), -1);
+%=============================================================================
+builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
+if ~isfile(builderFile)
+ return
+end
+%=============================================================================
+TMPDIR = tempdir();
+if ismac()
+ TMPDIR = ['/private', TMPDIR];
+end
+%=============================================================================
+DEST_1 = [TMPDIR, 'zip_test_1.zip'];
+cd([nelsonroot(), '/module_skeleton'])
+R = zip(DEST_1, '*.m');
+REF1 = {'builder.m'};
+REF2 = {'builder.m', 'loader.m'};
+if length(R) == 2
+ assert_isequal(R, REF2);
+else
+ assert_isequal(R, REF1);
+end
+assert_istrue(isfile(DEST_1));
+%=============================================================================
+temp_dest = [TMPDIR, createGUID()];
+mkdir(temp_dest);
+cd(temp_dest);
+R1 = unzip(DEST_1);
+REF1 = {[temp_dest, '/builder.m']};
+REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
+if length(R1) == 2
+ assert_isequal(R1, REF2);
+else
+ assert_isequal(R1, REF1);
+end
+cd(tempdir());
+rmdir(temp_dest, 's');
+%=============================================================================
+cmd = 'R = zip(DEST_1, ''*.m'', [nelsonroot(), ''/modules_skeleton''])';
+assert_checkerror(cmd, _('Invalid root path.'));
+%=============================================================================
diff --git a/modules/file_archiver/tests/test_zip_2.m b/modules/file_archiver/tests/test_zip_2.m
new file mode 100644
index 0000000000..cb0ac85c11
--- /dev/null
+++ b/modules/file_archiver/tests/test_zip_2.m
@@ -0,0 +1,61 @@
+%=============================================================================
+% Copyright (c) 2016-present Allan CORNET (Nelson)
+%=============================================================================
+% This file is part of the Nelson.
+%=============================================================================
+% LICENCE_BLOCK_BEGIN
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU Lesser General Public
+% License as published by the Free Software Foundation; either
+% version 2.1 of the License, or (at your option) any later version.
+%
+% Alternatively, you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation; either version 2 of
+% the License, or (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU Lesser General Public License for more details.
+%
+% You should have received a copy of the GNU Lesser General Public
+% License along with this program. If not, see .
+% LICENCE_BLOCK_END
+%=============================================================================
+builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
+if ~isfile(builderFile)
+ return
+end
+%=============================================================================
+TMPDIR = tempdir();
+if ismac()
+ TMPDIR = ['/private', TMPDIR];
+end
+%=============================================================================
+DEST_2 = [TMPDIR, 'zip_test_2.zip'];
+cd([nelsonroot(), '/module_skeleton'])
+R = zip(DEST_2, [nelsonroot(), '/module_skeleton/*.m']);
+REF1 = {'builder.m'};
+REF2 = {'builder.m', 'loader.m'};
+if length(R) == 2
+ assert_isequal(R, REF2);
+else
+ assert_isequal(R, REF1);
+end
+assert_istrue(isfile(DEST_2));
+%=============================================================================
+temp_dest = [TMPDIR, createGUID()];
+mkdir(temp_dest);
+cd(temp_dest);
+R2 = unzip(DEST_2);
+REF1 = {[temp_dest, '/builder.m']};
+REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
+if length(R2) == 2
+ assert_isequal(R2, REF2);
+else
+ assert_isequal(R2, REF1);
+end
+cd(tempdir());
+rmdir(temp_dest, 's');
+%=============================================================================
diff --git a/modules/file_archiver/tests/test_zip.m b/modules/file_archiver/tests/test_zip_3.m
similarity index 74%
rename from modules/file_archiver/tests/test_zip.m
rename to modules/file_archiver/tests/test_zip_3.m
index 96cc4e64c5..4497a40d4d 100644
--- a/modules/file_archiver/tests/test_zip.m
+++ b/modules/file_archiver/tests/test_zip_3.m
@@ -23,9 +23,6 @@
% License along with this program. If not, see .
% LICENCE_BLOCK_END
%=============================================================================
-assert_isequal(nargin('zip'), -3);
-assert_isequal(nargout('zip'), -1);
-%=============================================================================
builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
if ~isfile(builderFile)
return
@@ -36,58 +33,6 @@
TMPDIR = ['/private', TMPDIR];
end
%=============================================================================
-DEST_1 = [TMPDIR, 'zip_test_1.zip'];
-cd([nelsonroot(), '/module_skeleton'])
-R = zip(DEST_1, '*.m');
-REF1 = {'builder.m'};
-REF2 = {'builder.m', 'loader.m'};
-if length(R) == 2
- assert_isequal(R, REF2);
-else
- assert_isequal(R, REF1);
-end
-assert_istrue(isfile(DEST_1));
-%=============================================================================
-DEST_2 = [TMPDIR, 'zip_test_2.zip'];
-cd([nelsonroot(), '/module_skeleton'])
-R = zip(DEST_2, [nelsonroot(), '/module_skeleton/*.m']);
-REF1 = {'builder.m'};
-REF2 = {'builder.m', 'loader.m'};
-if length(R) == 2
- assert_isequal(R, REF2);
-else
- assert_isequal(R, REF1);
-end
-assert_istrue(isfile(DEST_2));
-%=============================================================================
-temp_dest = [TMPDIR, createGUID()];
-mkdir(temp_dest);
-cd(temp_dest);
-R1 = unzip(DEST_1);
-REF1 = {[temp_dest, '/builder.m']};
-REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
-if length(R1) == 2
- assert_isequal(R1, REF2);
-else
- assert_isequal(R1, REF1);
-end
-cd(tempdir());
-rmdir(temp_dest, 's');
-%=============================================================================
-temp_dest = [TMPDIR, createGUID()];
-mkdir(temp_dest);
-cd(temp_dest);
-R2 = unzip(DEST_2);
-REF1 = {[temp_dest, '/builder.m']};
-REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
-if length(R2) == 2
- assert_isequal(R2, REF2);
-else
- assert_isequal(R2, REF1);
-end
-cd(tempdir());
-rmdir(temp_dest, 's');
-%=============================================================================
DEST_3 = [TMPDIR, 'zip_test_3.zip'];
R3 = zip(DEST_3, [nelsonroot(), '/module_skeleton']);
REF = {'module_skeleton/builder.m', ...
@@ -205,6 +150,3 @@
info = dir(DEST_5);
assert_istrue(info.bytes > 0);
%=============================================================================
-cmd = 'R = zip(DEST_1, ''*.m'', [nelsonroot(), ''/modules_skeleton''])';
-assert_checkerror(cmd, _('Invalid root path.'));
-%=============================================================================
diff --git a/modules/files_folders_functions/tests/test_cd.m b/modules/files_folders_functions/tests/test_cd.m
index 3fa0c1c4a1..9cd934a25a 100644
--- a/modules/files_folders_functions/tests/test_cd.m
+++ b/modules/files_folders_functions/tests/test_cd.m
@@ -69,3 +69,9 @@
newDirectory = pwd();
assert_isequal(currentDirectory, newDirectory);
%=============================================================================
+temp_dest = [TMPDIR, createGUID()];
+mkdir(temp_dest);
+cd(temp_dest);
+currentDirectory = pwd();
+assert_isequal(currentDirectory, temp_dest);
+%=============================================================================
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..d8cc09d685 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 @@
-
-
@@ -325,6 +344,7 @@
+
diff --git a/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters b/modules/interpreter/src/c/nlsInterpreter.vcxproj.filters
index d4339476de..b03cbb2ce7 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
+
@@ -376,6 +433,9 @@
Header Files
+
+ Header Files
+
diff --git a/modules/interpreter/src/cpp/CommandQueue.cpp b/modules/interpreter/src/cpp/CommandQueue.cpp
index 083e459fe5..85d24a4370 100644
--- a/modules/interpreter/src/cpp/CommandQueue.cpp
+++ b/modules/interpreter/src/cpp/CommandQueue.cpp
@@ -27,11 +27,7 @@
//=============================================================================
namespace Nelson {
//=============================================================================
-CommandQueue::CommandQueue()
-{
- std::lock_guard lock(m_mutex);
- // commands.reserve(4096);
-}
+CommandQueue::CommandQueue() { std::lock_guard lock(m_mutex); }
//=============================================================================
CommandQueue::~CommandQueue()
{
diff --git a/modules/interpreter/src/cpp/Context.cpp b/modules/interpreter/src/cpp/Context.cpp
index 3a27436fd4..f020b7fbfb 100644
--- a/modules/interpreter/src/cpp/Context.cpp
+++ b/modules/interpreter/src/cpp/Context.cpp
@@ -237,19 +237,6 @@ Context::lookupFunction(const std::string& funcName, FunctionDefPtr& val, bool b
FunctionDefPtr functionDefInMem = nullptr;
if (FunctionsInMemory::getInstance()->find(funcName, val)) {
- /*
- if (val->type() == NLS_MACRO_FUNCTION || val->type() == NLS_MEX_FUNCTION) {
- std::wstring pathname = val->getPath();
- if (PathFuncManager::getInstance()->isAvailablePath(pathname)) {
- return true;
- } else {
- functionDefInMem = val;
- val = nullptr;
- }
- } else {
- return true;
- }
- */
return true;
}
diff --git a/modules/interpreter/src/cpp/Evaluator.cpp b/modules/interpreter/src/cpp/Evaluator.cpp
index 0472ae1d56..5bd086013b 100644
--- a/modules/interpreter/src/cpp/Evaluator.cpp
+++ b/modules/interpreter/src/cpp/Evaluator.cpp
@@ -1987,6 +1987,9 @@ Evaluator::statement(AbstractSyntaxTreePtr t)
void
Evaluator::block(AbstractSyntaxTreePtr t)
{
+ if (t == nullptr) {
+ return;
+ }
try {
AbstractSyntaxTreePtr s = t->down;
if (state < NLS_STATE_QUIT) {
@@ -4197,7 +4200,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