diff options
author | 2016-02-21 11:48:45 +0100 | |
---|---|---|
committer | 2016-02-21 11:48:45 +0100 | |
commit | cc24a339d8c0517259084b5c178d784626ba965c (patch) | |
tree | 9868e9687b5802ae0a3733712a3bbeb3bc75c953 /3rdparty/luv/examples/uvbook/onchange.lua | |
parent | b5daabda5495dea5c50e17961ecfed2ea8619d76 (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
Second attempt
Diffstat (limited to '3rdparty/luv/examples/uvbook/onchange.lua')
-rw-r--r-- | 3rdparty/luv/examples/uvbook/onchange.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/3rdparty/luv/examples/uvbook/onchange.lua b/3rdparty/luv/examples/uvbook/onchange.lua new file mode 100644 index 00000000000..07b3f9b1d78 --- /dev/null +++ b/3rdparty/luv/examples/uvbook/onchange.lua @@ -0,0 +1,30 @@ +local uv = require('luv') + +if #arg==0 then + print(string.format("Usage: %s <command> <file1> [file2 ...]",arg[0])); + return +end + +for i=1,#arg do + local fse = uv.new_fs_event() + assert(uv.fs_event_start(fse,arg[i],{ + --"watch_entry"=true,"stat"=true, + recursive=true + },function (err,fname,status) + if(err) then + print("Error "..err) + else + print(string.format('Change detected in %s', + uv.fs_event_getpath(fse))) + for k,v in pairs(status) do + print(k,v) + end + print('file changed:'..(fname and fname or '')) + end + end)) + +end + +uv.run('default') +uv.loop_close() + |