-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig
More file actions
26 lines (24 loc) · 699 Bytes
/
config
File metadata and controls
26 lines (24 loc) · 699 Bytes
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
local lfs = require 'lfs'
local os = require 'os'
local stat = require 'posix.sys.stat'
function is_file(name)
local st = stat.stat(name)
return st ~= nil and stat.S_ISREG(st.st_mode) ~= 0
end
local dirs = { '/etc/cpp-config-lua.d', os.getenv("HOME")..'/.config/cpp-config-lua' }
for _,v in ipairs(dirs) do
dir = io.open(v, 'r')
if dir ~= nil then
local dcontent = {}
for f in lfs.dir(v) do
table.insert(dcontent, f)
end
table.sort(dcontent)
for _,f in pairs(dcontent) do
if is_file(v..'/'..f) then
pcall(function() dofile(v..'/'..f) end)
end
end
io.close(dir)
end
end