/usr/share/lua/5.1/cqueues/notify.lua is in lua-cqueues 20161214-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | local loader = function(loader, ...)
local cqueues = require("cqueues")
local notify = require("_cqueues.notify")
local strerror = require("cqueues.errno").strerror
local ALL = notify.ALL
local function oops(self, op, why)
local msg = string.format("notify.%s: %s", op, strerror(why))
error(msg)
end
--
-- notify:get
--
local get; get = notify.interpose("get", function(self, timeout)
local deadline = timeout and (cqueues.monotime() + timeout)
local changes, filename
local ready = function()
local okay, why = self:step()
if not okay then
oops(self, "get", why)
end
changes, filename = get(self)
return changes
end
while not ready() do
if deadline then
local curtime = cqueues.monotime()
if curtime >= deadline then
return nil
else
cqueues.poll(self, deadline - curtime)
end
else
cqueues.poll(self)
end
end
return changes, filename
end)
--
-- notify:changes
--
notify.interpose("changes", function(self, timeout)
return function()
return self:get(timeout)
end
end)
--
-- notify:add
--
local add; add = notify.interpose("add", function(self, name, flags)
local okay, why = add(self, name, flags or ALL)
if not okay then
oops(self, "add", why)
end
return true
end)
notify.loader = loader
return notify
end
return loader(loader, ...)
|