开源软件名称(OpenSource Name):hoelzro/linotify开源软件地址(OpenSource Url):https://github.com/hoelzro/linotify开源编程语言(OpenSource Language):C 87.5%开源软件介绍(OpenSource Introduction):linotifyA Lua binding for the Linux inotify library BuildingTo build UsageAll of the constants are contained in the The only function to be found in the inotify table is
Inotify handles have a variety of methods: handle:read()Reads events from the handle, returning a table. Each element of the table
is itself a table, with the members of the handle:events()Returns an iterator that reads events from the handle, one at a time.
Each value yielded from the iterator is a table with the members of the
handle:close()Closes the inotify event handle. This is done automatically on garbage collection. handle:addwatch(path, [event_masks...])Adds a watch on All of the values in -- Event masks passed as arguments
local handle = inotify.init()
local wd = handle:addwatch('/tmp/foo/', inotify.IN_CREATE, inotify.IN_MOVE)
-- Event masks passed as a single, manually OR'd variable
local handle = inotify.init()
local options = bit.bor(inotify.IN_CREATE, inotify.IN_MOVE)
local wd = handle:addwatch('/tmp/foo/', options) handle:rmwatch(watchid)Removes the watch specified by watchid from the list of watches for this
inotify handle. Returns true on success, and handle:fileno()Returns the integer file descriptor for the given handle. Useful when used in combination with an event loop. handle:getfd()Alias for handle:fileno(). Examplelocal inotify = require 'inotify'
local handle = inotify.init()
-- Watch for new files and renames
local wd = handle:addwatch('/home/rob/', inotify.IN_CREATE, inotify.IN_MOVE)
local events = handle:read()
for _, ev in ipairs(events) do
print(ev.name .. ' was created or renamed')
end
-- Done automatically on close, I think, but kept to be thorough
handle:rmwatch(wd)
handle:close() Example (Iterator)local inotify = require 'inotify'
local handle = inotify.init()
-- Watch for new files and renames
local wd = handle:addwatch('/home/rob/', inotify.IN_CREATE, inotify.IN_MOVE)
for ev in handle:events() do
print(ev.name .. ' was created or renamed')
end
-- Done automatically on close, I think, but kept to be thorough
handle:rmwatch(wd)
handle:close() No More Global TableAs of version 0.3, the global local inotify = require 'inotify' |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论