diff options
| -rw-r--r-- | xmake/core/base/fwatcher.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/fwatcher.lua | 26 |
2 files changed, 35 insertions, 1 deletions
diff --git a/xmake/core/base/fwatcher.lua b/xmake/core/base/fwatcher.lua index da6d4c2a5..00ee35718 100644 --- a/xmake/core/base/fwatcher.lua +++ b/xmake/core/base/fwatcher.lua @@ -29,6 +29,8 @@ local scheduler = require("base/scheduler") -- save original interfaces fwatcher._open = fwatcher._open or fwatcher.open +fwatcher._add = fwatcher._add or fwatcher.add +fwatcher._remove = fwatcher._remove or fwatcher.remove fwatcher._wait = fwatcher._wait or fwatcher.wait fwatcher._close = fwatcher._close or fwatcher.close @@ -47,6 +49,14 @@ function _instance:otype() return 4 end +-- add watch directory, e.g. {recursion = true} +function _instance:add(watchdir, opt) +end + +-- remove watch directory +function _instance:remove(watchdir) +end + -- wait event -- -- @param timeout the timeout diff --git a/xmake/core/sandbox/modules/import/core/base/fwatcher.lua b/xmake/core/sandbox/modules/import/core/base/fwatcher.lua index db3dbdbc5..910c033a4 100644 --- a/xmake/core/sandbox/modules/import/core/base/fwatcher.lua +++ b/xmake/core/sandbox/modules/import/core/base/fwatcher.lua @@ -18,5 +18,29 @@ -- @file fwatcher.lua -- +-- define module +local sandbox_core_base_fwatcher = sandbox_core_base_fwatcher or {} + +-- load modules +local fwatcher = require("base/fwatcher") +local raise = require("sandbox/modules/raise") + +-- add watch directory +function sandbox_core_base_fwatcher.add(watchdir, opt) + local ok, errors = fwatcher.add(watchdir, opt) + if not ok then + raise(errors) + end +end + +-- remove watch directory +function sandbox_core_base_fwatcher.remove(watchdir) + local ok, errors = fwatcher.remove(watchdir) + if not ok then + raise(errors) + end +end + -- return module -return require("base/fwatcher") +return sandbox_core_base_fwatcher + |
