Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sfifs = {}
- sfifs.comp = require("component")
- function sfifs.getAllFiles(filesystem, path)
- local list = sfifs.comp.list()
- for address, type in pairs(list) do
- if(address == filesystem.address and type == "filesystem") then
- local list = filesystem.list(path)
- local files = {}
- if(#path > 0 and string.sub(path, #path, #path) ~= "/") then
- path = path.."/"
- end
- for i = 1, #list do
- if(filesystem.isDirectory(path.."/"..list[i])) then
- local tmp = sfifs.ginf(filesystem, path.."/"..list[i])
- for v = 1, #tmp do
- files[#files+1] = tmp[v]
- end
- else
- files[#files+1] = path..list[i]
- end
- end
- return files
- end
- end
- end
- function sfifs.searchFile(filesystem, path, filename)
- local files = sfifs.getAllFiles(filesystem, path)
- local nowfilename = ""
- local rez = ""
- local filesFound = {}
- if(files ~= nil and #files > 0) then
- for i = 1, #files do
- nowfilename = string.match(files[i], ".+/(.+)")
- if(nowfilename == nil) then
- nowfilename = files[i]
- end
- rez = string.match(nowfilename, filename)
- if(rez ~= nil) then
- filesFound[#filesFound+1] = files[i]
- end
- end
- end
- return filesFound
- end
- function sfifs.ginf(filesystem, path)
- local list = filesystem.list(path)
- local files = {}
- for i = 1,#list do
- if(filesystem.isDirectory(path..list[i])) then
- local tmp = sfifs.ginf(filesystem, path..list[i])
- for v = 1, #tmp do
- files[#files+1] = tmp[v]
- end
- else
- files[#files+1] = path..list[i]
- --print(path..list[i])
- end
- end
- return files
- end
- return sfifs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement