1234567891011121314 |
- local lfs = require("lfs")
- -- coroutine that watches files and calls the callback if they change
- return function(filename, callback)
- lastUpdated = -1 --lfs.attributes(filename).modification
- while(true) do
- local newTime = lfs.attributes(filename).modification
- if(newTime > lastUpdated) then
- callback(filename)
- lastUpdated = newTime
- end
- coroutine.yield()
- end
- end
|