Добавление программы: find
Программа откопанная где то внутри моего эмулятора CraftOS-PC. В теории должна быть рабочая везде.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
-- File finder.
|
||||
-- by H1N1, 2026
|
||||
|
||||
-- TODO: make help page!
|
||||
|
||||
local function listdir(path, findpattern)
|
||||
|
||||
local list = fs.list(path)
|
||||
|
||||
for k, v in pairs(list) do
|
||||
filename = path .. "/" .. v
|
||||
if fs.isDir(filename) then
|
||||
listdir(filename, findpattern)
|
||||
else
|
||||
|
||||
if findpattern then
|
||||
local s, e = filename:find(findpattern)
|
||||
if s then
|
||||
local ls = filename:sub(1, s-1)
|
||||
local h = filename:sub(s, e)
|
||||
local le = filename:sub(e+1)
|
||||
local defcolor = term.getTextColor()
|
||||
write(ls)
|
||||
term.setTextColor(colors.red)
|
||||
write(h)
|
||||
term.setTextColor(defcolor)
|
||||
print(le)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local args = {...}
|
||||
listdir("", args[1])
|
||||
Reference in New Issue
Block a user