Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ls(path,opts_in)
- local opts={
- msglimit=50,
- msgtimeout=100000,
- }
- if opts_in then
- for k,v in pairs(opts_in) do
- opts[k]=v
- end
- end
- local t,msg=os.listdir(path,opts.listall)
- if not t then
- return false,msg
- end
- local b=msg_batcher{
- batchsize=opts.msglimit,
- timeoute=opts.msgtimeout
- }
- if path=='A/' then
- path = 'A'
- end
- for i,v in ipairs(t) do
- if not opts.match or string.match(v,opts.match) then
- if opts.stat then
- local st,msg=os.stat(path..'/'..v)
- if not st then
- return false,msg
- end
- if opts.stat == '/' then
- if st.is_dir then
- b:write(v .. '/')
- else
- b:write(v)
- end
- elseif opts.stat == '*' then
- st.name=v
- b:write(st)
- end
- else
- b:write(t[i])
- end
- end
- end
- b:flush()
- return true
- end
Add Comment
Please, Sign In to add comment