Resolved merge conflicts by accepting remote library changes
This commit is contained in:
commit
aa8a02b1de
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
||||
|
||||
project(efsw)
|
||||
|
||||
@ -97,12 +97,16 @@ elseif(WIN32)
|
||||
src/efsw/FileWatcherWin32.cpp
|
||||
src/efsw/WatcherWin32.cpp
|
||||
)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR
|
||||
${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
list(APPEND EFSW_CPP_SOURCE
|
||||
src/efsw/FileWatcherInotify.cpp
|
||||
src/efsw/WatcherInotify.cpp
|
||||
)
|
||||
|
||||
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")
|
||||
list(APPEND EFSW_CPP_SOURCE
|
||||
src/efsw/FileWatcherKqueue.cpp
|
||||
|
||||
64
premake4.lua
64
premake4.lua
@ -1,13 +1,63 @@
|
||||
newoption { trigger = "verbose", description = "Build efsw with verbose mode." }
|
||||
newoption { trigger = "strip-symbols", description = "Strip debugging symbols in other file ( only for relwithdbginfo configuration )." }
|
||||
newoption { trigger = "thread-sanitizer", description ="Compile with ThreadSanitizer." }
|
||||
newoption { trigger = "address-sanitizer", description ="Compile with AddressSanitizer." }
|
||||
|
||||
efsw_major_version = "1"
|
||||
efsw_minor_version = "5"
|
||||
efsw_patch_version = "0"
|
||||
efsw_version = efsw_major_version .. "." .. efsw_minor_version .. "." .. efsw_patch_version
|
||||
|
||||
function get_include_paths()
|
||||
local function _insert_include_paths( file )
|
||||
local function _trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
local paths = { }
|
||||
local lines = file:read('*all')
|
||||
|
||||
for line in string.gmatch(lines, '([^\n]+)')
|
||||
do
|
||||
table.insert( paths, _trim( line ) )
|
||||
end
|
||||
|
||||
file:close()
|
||||
|
||||
return paths
|
||||
end
|
||||
|
||||
local file = io.popen( "echo | gcc -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -v '#' | grep '/'", 'r' )
|
||||
local include_paths = _insert_include_paths( file )
|
||||
|
||||
if next(include_paths) == nil then
|
||||
file = io.popen( "echo | clang++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -v '#' | grep '/' | grep -v 'nonexistent'", 'r' )
|
||||
|
||||
include_paths = _insert_include_paths( file )
|
||||
|
||||
if next(include_paths) == nil then
|
||||
table.insert( include_paths, "/usr/include" )
|
||||
table.insert( include_paths, "/usr/local/include" )
|
||||
end
|
||||
end
|
||||
|
||||
return include_paths
|
||||
end
|
||||
|
||||
function inotify_header_exists()
|
||||
local efsw_include_paths = get_include_paths()
|
||||
|
||||
for _,v in pairs( efsw_include_paths )
|
||||
do
|
||||
local cur_path = v .. "/sys/inotify.h"
|
||||
|
||||
if os.isfile( cur_path ) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function string.starts(String,Start)
|
||||
if ( _ACTION ) then
|
||||
return string.sub(String,1,string.len(Start))==Start
|
||||
@ -38,14 +88,6 @@ function conf_warnings()
|
||||
links { "tsan" }
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["address-sanitizer"] then
|
||||
buildoptions { "-fsanitize=address" }
|
||||
linkoptions { "-fsanitize=address" }
|
||||
if not os.is("macosx") then
|
||||
links { "asan" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function conf_links()
|
||||
@ -68,6 +110,10 @@ function conf_excludes()
|
||||
elseif os.is("freebsd") then
|
||||
excludes { "src/efsw/WatcherInotify.cpp", "src/efsw/WatcherWin32.cpp", "src/efsw/WatcherFSEvents.cpp", "src/efsw/FileWatcherInotify.cpp", "src/efsw/FileWatcherWin32.cpp", "src/efsw/FileWatcherFSEvents.cpp" }
|
||||
end
|
||||
|
||||
if os.is("linux") and not inotify_header_exists() then
|
||||
defines { "EFSW_INOTIFY_NOSYS" }
|
||||
end
|
||||
end
|
||||
|
||||
solution "efsw"
|
||||
|
||||
74
premake5.lua
74
premake5.lua
@ -1,13 +1,63 @@
|
||||
newoption { trigger = "verbose", description = "Build efsw with verbose mode." }
|
||||
newoption { trigger = "strip-symbols", description = "Strip debugging symbols in other file ( only for relwithdbginfo configuration )." }
|
||||
newoption { trigger = "thread-sanitizer", description ="Compile with ThreadSanitizer." }
|
||||
newoption { trigger = "address-sanitizer", description ="Compile with AddressSanitizer." }
|
||||
newoption { trigger = "thread-sanitizer", description ="Compile with ThreadSanitizer" }
|
||||
|
||||
efsw_major_version = "1"
|
||||
efsw_minor_version = "5"
|
||||
efsw_patch_version = "0"
|
||||
efsw_version = efsw_major_version .. "." .. efsw_minor_version .. "." .. efsw_patch_version
|
||||
|
||||
function get_include_paths()
|
||||
local function _insert_include_paths( file )
|
||||
local function _trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
local paths = { }
|
||||
local lines = file:read('*all')
|
||||
|
||||
for line in string.gmatch(lines, '([^\n]+)')
|
||||
do
|
||||
table.insert( paths, _trim( line ) )
|
||||
end
|
||||
|
||||
file:close()
|
||||
|
||||
return paths
|
||||
end
|
||||
|
||||
local file = io.popen( "echo | gcc -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -v '#' | grep '/'", 'r' )
|
||||
local include_paths = _insert_include_paths( file )
|
||||
|
||||
if next(include_paths) == nil then
|
||||
file = io.popen( "echo | clang++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -v '#' | grep '/' | grep -v 'nonexistent'", 'r' )
|
||||
|
||||
include_paths = _insert_include_paths( file )
|
||||
|
||||
if next(include_paths) == nil then
|
||||
table.insert( include_paths, "/usr/include" )
|
||||
table.insert( include_paths, "/usr/local/include" )
|
||||
end
|
||||
end
|
||||
|
||||
return include_paths
|
||||
end
|
||||
|
||||
function inotify_header_exists()
|
||||
local efsw_include_paths = get_include_paths()
|
||||
|
||||
for _,v in pairs( efsw_include_paths )
|
||||
do
|
||||
local cur_path = v .. "/sys/inotify.h"
|
||||
|
||||
if os.isfile( cur_path ) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function string.starts(String,Start)
|
||||
if ( _ACTION ) then
|
||||
return string.sub(String,1,string.len(Start))==Start
|
||||
@ -38,14 +88,6 @@ function conf_warnings()
|
||||
links { "tsan" }
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["address-sanitizer"] then
|
||||
buildoptions { "-fsanitize=address" }
|
||||
linkoptions { "-fsanitize=address" }
|
||||
if not os.istarget("macosx") then
|
||||
links { "asan" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function conf_links()
|
||||
@ -68,6 +110,10 @@ function conf_excludes()
|
||||
elseif os.istarget("bsd") then
|
||||
excludes { "src/efsw/WatcherInotify.cpp", "src/efsw/WatcherWin32.cpp", "src/efsw/WatcherFSEvents.cpp", "src/efsw/FileWatcherInotify.cpp", "src/efsw/FileWatcherWin32.cpp", "src/efsw/FileWatcherFSEvents.cpp" }
|
||||
end
|
||||
|
||||
if os.istarget("linux") and not inotify_header_exists() then
|
||||
defines { "EFSW_INOTIFY_NOSYS" }
|
||||
end
|
||||
end
|
||||
|
||||
workspace "efsw"
|
||||
@ -156,6 +202,14 @@ workspace "efsw"
|
||||
optimize "On"
|
||||
targetname "efsw-test-reldbginfo"
|
||||
conf_warnings()
|
||||
|
||||
project "joomer-efsw-file-monitoring"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
links { "efsw-static-lib" }
|
||||
files { "src/joomer-efsw-file-monitoring.cpp" }
|
||||
includedirs { "include", "src" }
|
||||
conf_links()
|
||||
|
||||
project "efsw-test-stdc"
|
||||
kind "ConsoleApp"
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.10.2, 2019-11-10T01:12:11. -->
|
||||
@ -209,3 +210,216 @@
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
=======
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.10.2, 2019-11-10T01:12:11. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{55fc4913-4acc-49e6-b0d5-ebf25d4d498e}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{eb5b6178-a7a7-439e-ab01-e63b057196a1}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\programming\efsw\make\windows</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">true</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="GenericProjectManager.GenericMakeStep.OverrideMakeflags">false</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">%{buildDir}\..\..\bin\efsw-test-debug.exe</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run C:\programming\efsw\bin\efsw-test-debug.exe</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
>>>>>>> 0adf96dcdb6ba38e789d409ca1bf1fc149e60808
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
../../include/efsw/efsw.hpp
|
||||
../../premake5.lua
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
@ -213,3 +214,220 @@
|
||||
../../src/efsw/Debug.cpp
|
||||
../../include/efsw/efsw.h
|
||||
../../src/efsw/FileWatcherCWrapper.cpp
|
||||
=======
|
||||
../../include/efsw/efsw.hpp
|
||||
../../premake5.lua
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/platform/platformimpl.hpp
|
||||
../../src/efsw/platform/posix/ThreadImpl.hpp
|
||||
../../src/efsw/platform/posix/MutexImpl.hpp
|
||||
../../src/efsw/platform/posix/SystemImpl.hpp
|
||||
../../src/efsw/platform/posix/ThreadImpl.cpp
|
||||
../../src/efsw/platform/posix/MutexImpl.cpp
|
||||
../../src/efsw/platform/posix/SystemImpl.cpp
|
||||
../../src/efsw/platform/win/ThreadImpl.hpp
|
||||
../../src/efsw/platform/win/MutexImpl.hpp
|
||||
../../src/efsw/platform/win/SystemImpl.hpp
|
||||
../../src/efsw/platform/win/ThreadImpl.cpp
|
||||
../../src/efsw/platform/win/MutexImpl.cpp
|
||||
../../src/efsw/platform/win/SystemImpl.cpp
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/platform/posix/FileSystemImpl.hpp
|
||||
../../src/efsw/platform/posix/FileSystemImpl.cpp
|
||||
../../src/efsw/platform/win/FileSystemImpl.hpp
|
||||
../../src/efsw/platform/win/FileSystemImpl.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/Thread.hpp
|
||||
../../src/efsw/System.hpp
|
||||
../../src/efsw/Mutex.hpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileSystem.hpp
|
||||
../../src/efsw/FileInfo.hpp
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/efsw/sophist.h
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/Utf.hpp
|
||||
../../src/efsw/Thread.hpp
|
||||
../../src/efsw/System.hpp
|
||||
../../src/efsw/String.hpp
|
||||
../../src/efsw/Mutex.hpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileSystem.hpp
|
||||
../../src/efsw/FileInfo.hpp
|
||||
../../src/efsw/Utf.inl
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/String.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/test/efsw-test.cpp
|
||||
../../src/efsw/WatcherKqueue.hpp
|
||||
../../src/efsw/WatcherInotify.hpp
|
||||
../../src/efsw/WatcherGeneric.hpp
|
||||
../../src/efsw/Utf.hpp
|
||||
../../src/efsw/Thread.hpp
|
||||
../../src/efsw/System.hpp
|
||||
../../src/efsw/String.hpp
|
||||
../../src/efsw/Mutex.hpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileSystem.hpp
|
||||
../../src/efsw/FileInfo.hpp
|
||||
../../src/efsw/DirWatcherGeneric.hpp
|
||||
../../src/efsw/Debug.hpp
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/sophist.h
|
||||
../../src/efsw/Utf.inl
|
||||
../../src/efsw/WatcherKqueue.cpp
|
||||
../../src/efsw/WatcherInotify.cpp
|
||||
../../src/efsw/WatcherGeneric.cpp
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/String.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/Log.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/efsw/DirWatcherGeneric.cpp
|
||||
../../src/efsw/Debug.cpp
|
||||
../../premake4.lua
|
||||
../../src/efsw/WatcherKqueue.hpp
|
||||
../../src/efsw/WatcherInotify.hpp
|
||||
../../src/efsw/WatcherGeneric.hpp
|
||||
../../src/efsw/Utf.hpp
|
||||
../../src/efsw/Thread.hpp
|
||||
../../src/efsw/System.hpp
|
||||
../../src/efsw/String.hpp
|
||||
../../src/efsw/sophist.h
|
||||
../../src/efsw/Mutex.hpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileSystem.hpp
|
||||
../../src/efsw/FileInfo.hpp
|
||||
../../src/efsw/DirWatcherGeneric.hpp
|
||||
../../src/efsw/Debug.hpp
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/Utf.inl
|
||||
../../src/efsw/WatcherKqueue.cpp
|
||||
../../src/efsw/WatcherInotify.cpp
|
||||
../../src/efsw/WatcherGeneric.cpp
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/String.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/Log.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherImpl.cpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/efsw/DirWatcherGeneric.cpp
|
||||
../../src/efsw/Debug.cpp
|
||||
../../src/efsw/WatcherWin32.hpp
|
||||
../../src/efsw/WatcherKqueue.hpp
|
||||
../../src/efsw/WatcherInotify.hpp
|
||||
../../src/efsw/WatcherGeneric.hpp
|
||||
../../src/efsw/WatcherFSEvents.hpp
|
||||
../../src/efsw/Watcher.hpp
|
||||
../../src/efsw/Utf.hpp
|
||||
../../src/efsw/Thread.hpp
|
||||
../../src/efsw/System.hpp
|
||||
../../src/efsw/String.hpp
|
||||
../../src/efsw/sophist.h
|
||||
../../src/efsw/Mutex.hpp
|
||||
../../src/efsw/FileWatcherWin32.hpp
|
||||
../../src/efsw/FileWatcherKqueue.hpp
|
||||
../../src/efsw/FileWatcherInotify.hpp
|
||||
../../src/efsw/FileWatcherImpl.hpp
|
||||
../../src/efsw/FileWatcherGeneric.hpp
|
||||
../../src/efsw/FileWatcherFSEvents.hpp
|
||||
../../src/efsw/FileSystem.hpp
|
||||
../../src/efsw/FileInfo.hpp
|
||||
../../src/efsw/DirWatcherGeneric.hpp
|
||||
../../src/efsw/DirectorySnapshotDiff.hpp
|
||||
../../src/efsw/DirectorySnapshot.hpp
|
||||
../../src/efsw/Debug.hpp
|
||||
../../src/efsw/base.hpp
|
||||
../../src/efsw/Utf.inl
|
||||
../../src/efsw/WatcherWin32.cpp
|
||||
../../src/efsw/WatcherKqueue.cpp
|
||||
../../src/efsw/WatcherInotify.cpp
|
||||
../../src/efsw/WatcherGeneric.cpp
|
||||
../../src/efsw/WatcherFSEvents.cpp
|
||||
../../src/efsw/Watcher.cpp
|
||||
../../src/efsw/Thread.cpp
|
||||
../../src/efsw/System.cpp
|
||||
../../src/efsw/String.cpp
|
||||
../../src/efsw/Mutex.cpp
|
||||
../../src/efsw/Log.cpp
|
||||
../../src/efsw/FileWatcherWin32.cpp
|
||||
../../src/efsw/FileWatcherKqueue.cpp
|
||||
../../src/efsw/FileWatcherInotify.cpp
|
||||
../../src/efsw/FileWatcherImpl.cpp
|
||||
../../src/efsw/FileWatcherGeneric.cpp
|
||||
../../src/efsw/FileWatcherFSEvents.cpp
|
||||
../../src/efsw/FileWatcher.cpp
|
||||
../../src/efsw/FileSystem.cpp
|
||||
../../src/efsw/FileInfo.cpp
|
||||
../../src/efsw/DirWatcherGeneric.cpp
|
||||
../../src/efsw/DirectorySnapshotDiff.cpp
|
||||
../../src/efsw/DirectorySnapshot.cpp
|
||||
../../src/efsw/Debug.cpp
|
||||
../../include/efsw/efsw.h
|
||||
../../src/efsw/FileWatcherCWrapper.cpp
|
||||
>>>>>>> 0adf96dcdb6ba38e789d409ca1bf1fc149e60808
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
#include <algorithm>
|
||||
#include <efsw/Lock.hpp>
|
||||
#include <efsw/Mutex.hpp>
|
||||
#include <efsw/efsw.h>
|
||||
#include <efsw/efsw.hpp>
|
||||
#include <vector>
|
||||
@ -38,26 +35,32 @@ class Watcher_CAPI : public efsw::FileWatchListener {
|
||||
* globals
|
||||
*/
|
||||
static std::vector<Watcher_CAPI*> g_callbacks;
|
||||
static efsw::Mutex g_callbacksMutex;
|
||||
|
||||
Watcher_CAPI* find_callback( efsw_watcher watcher, efsw_pfn_fileaction_callback fn, void* param ) {
|
||||
efsw::Lock l( g_callbacksMutex );
|
||||
for ( Watcher_CAPI* callback : g_callbacks ) {
|
||||
for ( std::vector<Watcher_CAPI*>::iterator i = g_callbacks.begin(); i != g_callbacks.end();
|
||||
++i ) {
|
||||
Watcher_CAPI* callback = *i;
|
||||
|
||||
if ( callback->mFn == fn && callback->mWatcher == watcher && callback->mParam == param )
|
||||
return callback;
|
||||
return *i;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void remove_callback( efsw_watcher watcher ) {
|
||||
efsw::Lock l( g_callbacksMutex );
|
||||
auto found = std::find_if( g_callbacks.begin(), g_callbacks.end(),
|
||||
[watcher]( Watcher_CAPI* cb ) { return cb->mWatcher == watcher; } );
|
||||
if ( found != g_callbacks.end() ) {
|
||||
Watcher_CAPI* callback = *found;
|
||||
delete callback;
|
||||
g_callbacks.erase( found );
|
||||
Watcher_CAPI* remove_callback( efsw_watcher watcher ) {
|
||||
std::vector<Watcher_CAPI*>::iterator i = g_callbacks.begin();
|
||||
|
||||
while ( i != g_callbacks.end() ) {
|
||||
Watcher_CAPI* callback = *i;
|
||||
|
||||
if ( callback->mWatcher == watcher )
|
||||
i = g_callbacks.erase( i );
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*************************************************************************************************/
|
||||
@ -95,7 +98,6 @@ efsw_addwatch_withoptions( efsw_watcher watcher, const char* directory,
|
||||
|
||||
if ( callback == NULL ) {
|
||||
callback = new Watcher_CAPI( watcher, callback_fn, param, callback_fn_missed_file_actions );
|
||||
efsw::Lock l( g_callbacksMutex );
|
||||
g_callbacks.push_back( callback );
|
||||
}
|
||||
|
||||
|
||||
@ -7,11 +7,15 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef EFSW_INOTIFY_NOSYS
|
||||
#include <efsw/inotify-nosys.h>
|
||||
#else
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
#include <efsw/Debug.hpp>
|
||||
#include <efsw/FileSystem.hpp>
|
||||
#include <efsw/Lock.hpp>
|
||||
@ -126,16 +130,6 @@ WatchID FileWatcherInotify::addWatch( const std::string& directory, FileWatchLis
|
||||
}
|
||||
}
|
||||
|
||||
// The watch could exists if a file was moved between directories that are being watched
|
||||
// In that case we need to remove the local watch information but *keep* the inotify watch id
|
||||
// open, to be reused with the new watch.
|
||||
{
|
||||
Lock lock( mWatchesLock );
|
||||
auto watchIdExists = mWatches.find( wd );
|
||||
if ( watchIdExists != mWatches.end() )
|
||||
removeWatchLocked( wd, true );
|
||||
}
|
||||
|
||||
efDEBUG( "Added watch %s with id: %d\n", dir.c_str(), wd );
|
||||
|
||||
WatcherInotify* pWatch = new WatcherInotify();
|
||||
@ -149,7 +143,7 @@ WatchID FileWatcherInotify::addWatch( const std::string& directory, FileWatchLis
|
||||
|
||||
{
|
||||
Lock lock( mWatchesLock );
|
||||
mWatches[wd] = pWatch;
|
||||
mWatches.insert( std::make_pair( wd, pWatch ) );
|
||||
mWatchesRef[pWatch->Directory] = wd;
|
||||
}
|
||||
|
||||
@ -190,7 +184,7 @@ WatchID FileWatcherInotify::addWatch( const std::string& directory, FileWatchLis
|
||||
return wd;
|
||||
}
|
||||
|
||||
void FileWatcherInotify::removeWatchLocked( WatchID watchid, bool skipInotifyRemove ) {
|
||||
void FileWatcherInotify::removeWatchLocked( WatchID watchid ) {
|
||||
WatchMap::iterator iter = mWatches.find( watchid );
|
||||
if ( iter == mWatches.end() )
|
||||
return;
|
||||
@ -231,14 +225,12 @@ void FileWatcherInotify::removeWatchLocked( WatchID watchid, bool skipInotifyRem
|
||||
}
|
||||
}
|
||||
|
||||
if ( !skipInotifyRemove ) {
|
||||
int err = inotify_rm_watch( mFD, watchid );
|
||||
int err = inotify_rm_watch( mFD, watchid );
|
||||
|
||||
if ( err < 0 ) {
|
||||
efDEBUG( "Error removing watch %d: %s\n", watchid, strerror( errno ) );
|
||||
} else {
|
||||
efDEBUG( "Removed watch %s with id: %d\n", watch->Directory.c_str(), watchid );
|
||||
}
|
||||
if ( err < 0 ) {
|
||||
efDEBUG( "Error removing watch %d: %s\n", watchid, strerror( errno ) );
|
||||
} else {
|
||||
efDEBUG( "Removed watch %s with id: %d\n", watch->Directory.c_str(), watchid );
|
||||
}
|
||||
|
||||
efSAFE_DELETE( watch );
|
||||
@ -294,7 +286,7 @@ void FileWatcherInotify::run() {
|
||||
|
||||
WatcherInotify* curWatcher = NULL;
|
||||
WatcherInotify* currentMoveFrom = NULL;
|
||||
uint32_t currentMoveCookie = -1;
|
||||
u_int32_t currentMoveCookie = -1;
|
||||
bool lastWasMovedFrom = false;
|
||||
std::string prevOldFileName;
|
||||
|
||||
@ -332,31 +324,14 @@ void FileWatcherInotify::run() {
|
||||
if ( curWatcher ) {
|
||||
handleAction( curWatcher, (char*)pevent->name, pevent->mask );
|
||||
|
||||
// Check if this is the destination of a move
|
||||
if ( ( pevent->mask & IN_MOVED_TO ) && currentMoveFrom &&
|
||||
if ( ( pevent->mask & IN_MOVED_TO ) && curWatcher == currentMoveFrom &&
|
||||
pevent->cookie == currentMoveCookie ) {
|
||||
|
||||
// If the move happened between TWO DIFFERENT watched directories
|
||||
if ( curWatcher != currentMoveFrom ) {
|
||||
// We need to simulate a delete event, the IN_MOVED_TO will
|
||||
// generate an add event after
|
||||
handleAction( currentMoveFrom, currentMoveFrom->OldFileName,
|
||||
IN_DELETE );
|
||||
|
||||
// Clear the state on the source watcher so it doesn't
|
||||
// get processed again or stuck with stale data.
|
||||
currentMoveFrom->OldFileName = "";
|
||||
}
|
||||
// Else: If curWatcher == currentMoveFrom, it's a local rename.
|
||||
// handleAction() above already detected the OldFileName and
|
||||
// emitted a 'Moved' event correctly.
|
||||
|
||||
/// Pair processed successfully
|
||||
/// make pair success
|
||||
currentMoveFrom = NULL;
|
||||
currentMoveCookie = -1;
|
||||
} else if ( pevent->mask & IN_MOVED_FROM ) {
|
||||
// Previous event was moved from and current event is moved from
|
||||
// Treat it as a DELETE or moved outside watches
|
||||
// Treat it as a DELETE or moved ouside watches
|
||||
if ( lastWasMovedFrom && currentMoveFrom ) {
|
||||
mMovedOutsideWatches.push_back(
|
||||
std::make_pair( currentMoveFrom, prevOldFileName ) );
|
||||
@ -401,16 +376,6 @@ void FileWatcherInotify::run() {
|
||||
i += sizeof( struct inotify_event ) + pevent->len;
|
||||
}
|
||||
}
|
||||
|
||||
// If the last event was also IN_MODEV_FROM we didn't generate any event for that one
|
||||
// Treat it as a DELETE or moved outside watches
|
||||
if ( lastWasMovedFrom && currentMoveFrom ) {
|
||||
mMovedOutsideWatches.push_back(
|
||||
std::make_pair( currentMoveFrom, prevOldFileName ) );
|
||||
currentMoveFrom = NULL;
|
||||
lastWasMovedFrom = false;
|
||||
prevOldFileName.clear();
|
||||
}
|
||||
} else {
|
||||
// Here means no event received
|
||||
// If last event is IN_MOVED_FROM, we assume no IN_MOVED_TO
|
||||
@ -419,8 +384,7 @@ void FileWatcherInotify::run() {
|
||||
mMovedOutsideWatches.begin(), mMovedOutsideWatches.end(),
|
||||
[currentMoveFrom]( const std::pair<WatcherInotify*, std::string>& moved ) {
|
||||
return moved.first == currentMoveFrom;
|
||||
} ) == mMovedOutsideWatches.end() &&
|
||||
!currentMoveFrom->OldFileName.empty() ) {
|
||||
} ) == mMovedOutsideWatches.end() ) {
|
||||
mMovedOutsideWatches.push_back(
|
||||
std::make_pair( currentMoveFrom, currentMoveFrom->OldFileName ) );
|
||||
} else {
|
||||
@ -462,12 +426,6 @@ void FileWatcherInotify::run() {
|
||||
}
|
||||
|
||||
Watcher* watch = it->first;
|
||||
|
||||
// Clear the stale OldFileName.
|
||||
// Since this move is considered complete (moved outside),
|
||||
// the watcher should not be waiting for a pair anymore.
|
||||
watch->OldFileName = "";
|
||||
|
||||
const std::string& oldFileName = it->second;
|
||||
|
||||
/// Check if the file move was a folder already being watched
|
||||
@ -575,7 +533,7 @@ void FileWatcherInotify::handleAction( Watcher* watch, const std::string& filena
|
||||
Actions::Moved, watch->OldFileName );
|
||||
}
|
||||
|
||||
if ( watch->Recursive && FileSystem::isDirectory( fpath ) && !watch->OldFileName.empty() ) {
|
||||
if ( watch->Recursive && FileSystem::isDirectory( fpath ) ) {
|
||||
/// Update the new directory path
|
||||
std::string opath( watch->Directory + watch->OldFileName );
|
||||
FileSystem::dirAddSlashAtEnd( opath );
|
||||
|
||||
@ -73,7 +73,7 @@ class FileWatcherInotify : public FileWatcherImpl {
|
||||
private:
|
||||
void run();
|
||||
|
||||
void removeWatchLocked( WatchID watchid, bool skipInotifyRemove = false );
|
||||
void removeWatchLocked( WatchID watchid );
|
||||
|
||||
void checkForNewWatcher( Watcher* watch, std::string fpath );
|
||||
|
||||
|
||||
164
src/efsw/inotify-nosys.h
Normal file
164
src/efsw/inotify-nosys.h
Normal file
@ -0,0 +1,164 @@
|
||||
#ifndef _LINUX_INOTIFY_H
|
||||
#define _LINUX_INOTIFY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
* struct inotify_event - structure read from the inotify device for each event
|
||||
*
|
||||
* When you are watching a directory, you will receive the filename for events
|
||||
* such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
|
||||
*/
|
||||
struct inotify_event {
|
||||
int wd; /* watch descriptor */
|
||||
uint32_t mask; /* watch mask */
|
||||
uint32_t cookie; /* cookie to synchronize two events */
|
||||
uint32_t len; /* length (including nulls) of name */
|
||||
char name __flexarr; /* stub for possible name */
|
||||
};
|
||||
|
||||
/* the following are legal, implemented events that user-space can watch for */
|
||||
#define IN_ACCESS 0x00000001 /* File was accessed */
|
||||
#define IN_MODIFY 0x00000002 /* File was modified */
|
||||
#define IN_ATTRIB 0x00000004 /* Metadata changed */
|
||||
#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
|
||||
#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
|
||||
#define IN_OPEN 0x00000020 /* File was opened */
|
||||
#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
|
||||
#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
|
||||
#define IN_CREATE 0x00000100 /* Subfile was created */
|
||||
#define IN_DELETE 0x00000200 /* Subfile was deleted */
|
||||
#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
|
||||
#define IN_MOVE_SELF 0x00000800 /* Self was moved */
|
||||
|
||||
/* the following are legal events. they are sent as needed to any watch */
|
||||
#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
|
||||
#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
|
||||
#define IN_IGNORED 0x00008000 /* File was ignored */
|
||||
|
||||
/* helper events */
|
||||
#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
|
||||
#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
|
||||
|
||||
/* special flags */
|
||||
#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
|
||||
#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
|
||||
#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
|
||||
#define IN_ISDIR 0x40000000 /* event occurred against dir */
|
||||
#define IN_ONESHOT 0x80000000 /* only send event once */
|
||||
|
||||
/*
|
||||
* All of the events - we build the list by hand so that we can add flags in
|
||||
* the future and not break backward compatibility. Apps will get only the
|
||||
* events that they originally wanted. Be sure to add new events here!
|
||||
*/
|
||||
#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
|
||||
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
|
||||
IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
|
||||
IN_MOVE_SELF)
|
||||
|
||||
#if defined (__alpha__)
|
||||
# define __NR_inotify_init 444
|
||||
# define __NR_inotify_add_watch 445
|
||||
# define __NR_inotify_rm_watch 446
|
||||
|
||||
#elif defined (__arm__)
|
||||
# define __NR_inotify_init (__NR_SYSCALL_BASE+316)
|
||||
# define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
|
||||
# define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
|
||||
|
||||
#elif defined (__aarch64__)
|
||||
# define __NR_inotify_init 1043
|
||||
# define __NR_inotify_add_watch 27
|
||||
# define __NR_inotify_rm_watch 28
|
||||
|
||||
#elif defined (__frv__)
|
||||
# define __NR_inotify_init 291
|
||||
# define __NR_inotify_add_watch 292
|
||||
# define __NR_inotify_rm_watch 293
|
||||
|
||||
#elif defined(__i386__)
|
||||
# define __NR_inotify_init 291
|
||||
# define __NR_inotify_add_watch 292
|
||||
# define __NR_inotify_rm_watch 293
|
||||
|
||||
#elif defined (__ia64__)
|
||||
# define __NR_inotify_init 1277
|
||||
# define __NR_inotify_add_watch 1278
|
||||
# define __NR_inotify_rm_watch 1279
|
||||
|
||||
#elif defined (__mips__)
|
||||
# if _MIPS_SIM == _MIPS_SIM_ABI32
|
||||
# define __NR_inotify_init (__NR_Linux + 284)
|
||||
# define __NR_inotify_add_watch (__NR_Linux + 285)
|
||||
# define __NR_inotify_rm_watch (__NR_Linux + 286)
|
||||
# endif
|
||||
# if _MIPS_SIM == _MIPS_SIM_ABI64
|
||||
# define __NR_inotify_init (__NR_Linux + 243)
|
||||
# define __NR_inotify_add_watch (__NR_Linux + 243)
|
||||
# define __NR_inotify_rm_watch (__NR_Linux + 243)
|
||||
# endif
|
||||
# if _MIPS_SIM == _MIPS_SIM_NABI32
|
||||
# define __NR_inotify_init (__NR_Linux + 247)
|
||||
# define __NR_inotify_add_watch (__NR_Linux + 248)
|
||||
# define __NR_inotify_rm_watch (__NR_Linux + 249)
|
||||
# endif
|
||||
|
||||
#elif defined(__parisc__)
|
||||
# define __NR_inotify_init (__NR_Linux + 269)
|
||||
# define __NR_inotify_add_watch (__NR_Linux + 270)
|
||||
# define __NR_inotify_rm_watch (__NR_Linux + 271)
|
||||
|
||||
#elif defined(__powerpc__) || defined(__powerpc64__)
|
||||
# define __NR_inotify_init 275
|
||||
# define __NR_inotify_add_watch 276
|
||||
# define __NR_inotify_rm_watch 277
|
||||
|
||||
#elif defined (__s390__)
|
||||
# define __NR_inotify_init 284
|
||||
# define __NR_inotify_add_watch 285
|
||||
# define __NR_inotify_rm_watch 286
|
||||
|
||||
#elif defined (__sh__)
|
||||
# define __NR_inotify_init 290
|
||||
# define __NR_inotify_add_watch 291
|
||||
# define __NR_inotify_rm_watch 292
|
||||
|
||||
#elif defined (__sh64__)
|
||||
# define __NR_inotify_init 318
|
||||
# define __NR_inotify_add_watch 319
|
||||
# define __NR_inotify_rm_watch 320
|
||||
|
||||
#elif defined (__sparc__) || defined (__sparc64__)
|
||||
# define __NR_inotify_init 151
|
||||
# define __NR_inotify_add_watch 152
|
||||
# define __NR_inotify_rm_watch 156
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
# define __NR_inotify_init 253
|
||||
# define __NR_inotify_add_watch 254
|
||||
# define __NR_inotify_rm_watch 255
|
||||
|
||||
#else
|
||||
# error "Unsupported architecture!"
|
||||
#endif
|
||||
|
||||
static inline int inotify_init (void)
|
||||
{
|
||||
return syscall (__NR_inotify_init);
|
||||
}
|
||||
|
||||
static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
|
||||
{
|
||||
return syscall (__NR_inotify_add_watch, fd, name, mask);
|
||||
}
|
||||
|
||||
static inline int inotify_rm_watch (int fd, uint32_t wd)
|
||||
{
|
||||
return syscall (__NR_inotify_rm_watch, fd, wd);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LINUX_INOTIFY_H */
|
||||
222
src/joomer-efsw-file-monitoring.cpp
Normal file
222
src/joomer-efsw-file-monitoring.cpp
Normal file
@ -0,0 +1,222 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
|
||||
#include <efsw/FileSystem.hpp>
|
||||
#include <efsw/System.hpp>
|
||||
#include <efsw/efsw.hpp>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <cstring>
|
||||
#include "stb_image.h"
|
||||
#include "stb_image_write.h"
|
||||
|
||||
//void flip_image_horizontally(unsigned char* data, int width, int height, int channels);
|
||||
void flip_image_vertically(unsigned char* data, int width, int height, int channels);
|
||||
|
||||
bool STOP = false;
|
||||
|
||||
void sigend( int ) {
|
||||
std::cout << std::endl << "Bye bye" << std::endl;
|
||||
STOP = true;
|
||||
}
|
||||
|
||||
/// Processes a file action
|
||||
class UpdateListener : public efsw::FileWatchListener {
|
||||
public:
|
||||
UpdateListener() {}
|
||||
|
||||
std::string getActionName( efsw::Action action ) {
|
||||
switch ( action ) {
|
||||
case efsw::Actions::Add:
|
||||
|
||||
return "Add";
|
||||
case efsw::Actions::Modified:
|
||||
return "Modified";
|
||||
case efsw::Actions::Delete:
|
||||
return "Delete";
|
||||
case efsw::Actions::Moved:
|
||||
return "Moved";
|
||||
default:
|
||||
return "Bad Action";
|
||||
}
|
||||
}
|
||||
|
||||
void handleFileAction( efsw::WatchID watchid, const std::string& dir,
|
||||
const std::string& filename, efsw::Action action,
|
||||
std::string oldFilename = "" ) override {
|
||||
std::cout << "Watch ID " << watchid << " DIR ("
|
||||
<< dir + ") FILE (" +
|
||||
( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) +
|
||||
filename + ") has event "
|
||||
<< getActionName( action ) << std::endl;
|
||||
|
||||
// Check if a file was added (dropped)
|
||||
/*if (action == efsw::Actions::Add) {
|
||||
int width, height, channels;
|
||||
// Reconstruct the full path
|
||||
std::string fullPath = dir + filename;
|
||||
|
||||
// Add this delay
|
||||
efsw::System::sleep(500);
|
||||
|
||||
std::cout << "File dropped: " << filename << std::endl;
|
||||
std::cout << "Full path: " << fullPath << std::endl;
|
||||
unsigned char* image_data = stbi_load(fullPath.c_str(), &width, &height, &channels, 0);
|
||||
if (image_data)
|
||||
{
|
||||
std::cout << "DEBUG: Image loaded successfully. Flipping..." << std::endl;
|
||||
flip_image_vertically(image_data, width, height, channels);
|
||||
// --- Save the flipped image to a new temporary file ---
|
||||
std::string flipped_filename = "flipped_" + filename;
|
||||
stbi_write_jpg(flipped_filename.c_str(), width, height, channels, image_data, 100); // Quality 100
|
||||
stbi_image_free(image_data);
|
||||
|
||||
STOP = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will tell you if the path was wrong or the file was locked
|
||||
std::cout << "DEBUG: stbi_load failed for: " << fullPath << std::endl;
|
||||
std::cout << "Reason: " << stbi_failure_reason() << std::endl;
|
||||
}
|
||||
}*/
|
||||
if (action == efsw::Actions::Add || action == efsw::Actions::Modified) {
|
||||
// 1. Ignore the event if it's a file WE created
|
||||
if (filename.find("flipped_") == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string fullPath = dir + filename;
|
||||
|
||||
int width, height, channels;
|
||||
// Try to load
|
||||
unsigned char* image_data = stbi_load(fullPath.c_str(), &width, &height, &channels, 0);
|
||||
|
||||
// If it fails because the file is still being written, wait and try one more time
|
||||
if (!image_data) {
|
||||
efsw::System::sleep(300);
|
||||
image_data = stbi_load(fullPath.c_str(), &width, &height, &channels, 0);
|
||||
}
|
||||
|
||||
if (image_data) {
|
||||
std::cout << "Successfully loaded " << filename << " (" << width << "x" << height << ")" << std::endl;
|
||||
flip_image_vertically(image_data, width, height, channels);
|
||||
std::string flipped_filename = dir + "flipped_" + filename;
|
||||
stbi_write_jpg(flipped_filename.c_str(), width, height, channels, image_data, 100);
|
||||
stbi_image_free(image_data);
|
||||
STOP = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
efsw::WatchID handleWatchID( efsw::WatchID watchid ) {
|
||||
switch ( watchid ) {
|
||||
case efsw::Errors::FileNotFound:
|
||||
case efsw::Errors::FileRepeated:
|
||||
case efsw::Errors::FileOutOfScope:
|
||||
case efsw::Errors::FileRemote:
|
||||
case efsw::Errors::WatcherFailed:
|
||||
case efsw::Errors::Unspecified: {
|
||||
std::cout << efsw::Errors::Log::getLastErrorLog().c_str() << std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
std::cout << "Added WatchID: " << watchid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return watchid;
|
||||
}
|
||||
|
||||
void flip_image_vertically(unsigned char* data, int width, int height, int channels) {
|
||||
// ... (your vertical flip implementation from before)
|
||||
int row_stride = width * channels;
|
||||
unsigned char* temp_row = new unsigned char [row_stride];
|
||||
for (int y = 0; y < height / 2; ++y) {
|
||||
unsigned char* top_row = data + y * row_stride;
|
||||
unsigned char* bottom_row = data + (height - 1 - y) * row_stride;
|
||||
std::memcpy(temp_row, top_row, row_stride);
|
||||
std::memcpy(top_row, bottom_row, row_stride);
|
||||
std::memcpy(bottom_row, temp_row, row_stride);
|
||||
}
|
||||
delete[] temp_row;
|
||||
}
|
||||
|
||||
int main( int argc, char** argv ) {
|
||||
signal( SIGABRT, sigend );
|
||||
signal( SIGINT, sigend );
|
||||
signal( SIGTERM, sigend );
|
||||
|
||||
std::cout << "Press ^C to exit demo" << std::endl;
|
||||
|
||||
bool commonTest = true;
|
||||
bool useGeneric = false;
|
||||
std::string path;
|
||||
|
||||
if ( argc >= 2 ) {
|
||||
path = std::string( argv[1] );
|
||||
|
||||
if ( efsw::FileSystem::isDirectory( path ) ) {
|
||||
commonTest = false;
|
||||
}
|
||||
|
||||
if ( argc >= 3 ) {
|
||||
if ( std::string( argv[2] ) == "true" ) {
|
||||
useGeneric = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateListener* ul = new UpdateListener();
|
||||
|
||||
/// create the file watcher object
|
||||
efsw::FileWatcher fileWatcher( useGeneric );
|
||||
|
||||
fileWatcher.followSymlinks( false );
|
||||
fileWatcher.allowOutOfScopeLinks( false );
|
||||
|
||||
if ( commonTest ) {
|
||||
std::string CurPath( efsw::System::getProcessPath() );
|
||||
|
||||
std::cout << "CurPath: " << CurPath.c_str() << std::endl;
|
||||
|
||||
/// starts watching
|
||||
fileWatcher.watch();
|
||||
|
||||
/// add a watch to the system
|
||||
handleWatchID( fileWatcher.addWatch( CurPath + "test", ul, true ) );
|
||||
|
||||
/// adds another watch after started watching...
|
||||
efsw::System::sleep( 100 );
|
||||
|
||||
efsw::WatchID watchID =
|
||||
handleWatchID( fileWatcher.addWatch( CurPath + "test2", ul, true ) );
|
||||
|
||||
/// delete the watch
|
||||
if ( watchID > 0 ) {
|
||||
efsw::System::sleep( 1000 );
|
||||
fileWatcher.removeWatch( watchID );
|
||||
}
|
||||
} else {
|
||||
if ( fileWatcher.addWatch( path, ul, true ) > 0 ) {
|
||||
fileWatcher.watch();
|
||||
|
||||
std::cout << "Watching directory: " << path.c_str() << std::endl;
|
||||
|
||||
if ( useGeneric ) {
|
||||
std::cout << "Using generic backend watcher" << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cout << "Error trying to watch directory: " << path.c_str() << std::endl;
|
||||
std::cout << efsw::Errors::Log::getLastErrorLog().c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
while ( !STOP ) {
|
||||
efsw::System::sleep( 100 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
7988
src/stb_image.h
Normal file
7988
src/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
1724
src/stb_image_write.h
Normal file
1724
src/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load Diff
139
src/test/efsw-test.cpp
Normal file
139
src/test/efsw-test.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include <efsw/FileSystem.hpp>
|
||||
#include <efsw/System.hpp>
|
||||
#include <efsw/efsw.hpp>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
|
||||
bool STOP = false;
|
||||
|
||||
void sigend( int ) {
|
||||
std::cout << std::endl << "Bye bye" << std::endl;
|
||||
STOP = true;
|
||||
}
|
||||
|
||||
/// Processes a file action
|
||||
class UpdateListener : public efsw::FileWatchListener {
|
||||
public:
|
||||
UpdateListener() {}
|
||||
|
||||
std::string getActionName( efsw::Action action ) {
|
||||
switch ( action ) {
|
||||
case efsw::Actions::Add:
|
||||
return "Add";
|
||||
case efsw::Actions::Modified:
|
||||
return "Modified";
|
||||
case efsw::Actions::Delete:
|
||||
return "Delete";
|
||||
case efsw::Actions::Moved:
|
||||
return "Moved";
|
||||
default:
|
||||
return "Bad Action";
|
||||
}
|
||||
}
|
||||
|
||||
void handleFileAction( efsw::WatchID watchid, const std::string& dir,
|
||||
const std::string& filename, efsw::Action action,
|
||||
std::string oldFilename = "" ) override {
|
||||
std::cout << "Watch ID " << watchid << " DIR ("
|
||||
<< dir + ") FILE (" +
|
||||
( oldFilename.empty() ? "" : "from file " + oldFilename + " to " ) +
|
||||
filename + ") has event "
|
||||
<< getActionName( action ) << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
efsw::WatchID handleWatchID( efsw::WatchID watchid ) {
|
||||
switch ( watchid ) {
|
||||
case efsw::Errors::FileNotFound:
|
||||
case efsw::Errors::FileRepeated:
|
||||
case efsw::Errors::FileOutOfScope:
|
||||
case efsw::Errors::FileRemote:
|
||||
case efsw::Errors::WatcherFailed:
|
||||
case efsw::Errors::Unspecified: {
|
||||
std::cout << efsw::Errors::Log::getLastErrorLog().c_str() << std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
std::cout << "Added WatchID: " << watchid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return watchid;
|
||||
}
|
||||
|
||||
int main( int argc, char** argv ) {
|
||||
signal( SIGABRT, sigend );
|
||||
signal( SIGINT, sigend );
|
||||
signal( SIGTERM, sigend );
|
||||
|
||||
std::cout << "Press ^C to exit demo" << std::endl;
|
||||
|
||||
bool commonTest = true;
|
||||
bool useGeneric = false;
|
||||
std::string path;
|
||||
|
||||
if ( argc >= 2 ) {
|
||||
path = std::string( argv[1] );
|
||||
|
||||
if ( efsw::FileSystem::isDirectory( path ) ) {
|
||||
commonTest = false;
|
||||
}
|
||||
|
||||
if ( argc >= 3 ) {
|
||||
if ( std::string( argv[2] ) == "true" ) {
|
||||
useGeneric = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateListener* ul = new UpdateListener();
|
||||
|
||||
/// create the file watcher object
|
||||
efsw::FileWatcher fileWatcher( useGeneric );
|
||||
|
||||
fileWatcher.followSymlinks( false );
|
||||
fileWatcher.allowOutOfScopeLinks( false );
|
||||
|
||||
if ( commonTest ) {
|
||||
std::string CurPath( efsw::System::getProcessPath() );
|
||||
|
||||
std::cout << "CurPath: " << CurPath.c_str() << std::endl;
|
||||
|
||||
/// starts watching
|
||||
fileWatcher.watch();
|
||||
|
||||
/// add a watch to the system
|
||||
handleWatchID( fileWatcher.addWatch( CurPath + "test", ul, true ) );
|
||||
|
||||
/// adds another watch after started watching...
|
||||
efsw::System::sleep( 100 );
|
||||
|
||||
efsw::WatchID watchID =
|
||||
handleWatchID( fileWatcher.addWatch( CurPath + "test2", ul, true ) );
|
||||
|
||||
/// delete the watch
|
||||
if ( watchID > 0 ) {
|
||||
efsw::System::sleep( 1000 );
|
||||
fileWatcher.removeWatch( watchID );
|
||||
}
|
||||
} else {
|
||||
if ( fileWatcher.addWatch( path, ul, true ) > 0 ) {
|
||||
fileWatcher.watch();
|
||||
|
||||
std::cout << "Watching directory: " << path.c_str() << std::endl;
|
||||
|
||||
if ( useGeneric ) {
|
||||
std::cout << "Using generic backend watcher" << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cout << "Error trying to watch directory: " << path.c_str() << std::endl;
|
||||
std::cout << efsw::Errors::Log::getLastErrorLog().c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
while ( !STOP ) {
|
||||
efsw::System::sleep( 100 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user