Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- problem = 0
- art = ""
- contain = ""
- number = 1
- local tFiles = {}
- probinhalt = {}
- infectinhalt = {}
- logfilename = "/PSAV/reports/log"..os.day().."."..os.time()..".log"
- file = fs.open("/PSAV/reports/logs.txt", "a")
- file.writeLine(logfilename)
- file.close()
- function report(dateipath, art, contain)
- local str = os.day().."\t"..textutils.formatTime(os.time(), true).."\t"..art.."\t"..dateipath.."\t"..contain
- file = fs.open(logfilename, "a")
- file.writeLine(str)
- file.close()
- number = number + 1
- end
- function replaceLine( path, line, text )
- if not tFiles[path] then return false end
- tFiles[path][line] = text
- return writeTable(path, tFiles[path] )
- end
- function check(datei)
- term.setTextColour(colors.white)
- write(datei.." ")
- if fs.isDir(datei) then
- term.setTextColour(colors.green)
- print("\(DIR\)")
- else
- term.setTextColour( colors.orange )
- print("")
- local f = io.open(datei, "r")
- local data = f:read("*a")
- f:close()
- term.setTextColour(colors.white)
- for i = 1, #probinhalt do
- if data:find (probinhalt[i]) then
- problem = problem + 1
- term.setTextColour(colors.red)
- print("> Found a problem in "..datei.."!")
- report(datei, "problem", probinhalt[i])
- else
- report(datei, "nothing", probinhalt[i])
- term.setTextColour(colors.lime)
- print("No problem in "..datei)
- end
- term.setTextColour( colors.white )
- end
- end
- term.setTextColour(colors.red)
- if problem > 1 or problem == 0 then
- print("Found "..problem.." problems!")
- term.setTextColour(colors.white)
- else
- print("Found "..problem.." problem!")
- term.setTextColour(colors.white)
- end
- end
- function ReadDir(dir)
- local dateien = fs.list(dir)
- for i = 1, #dateien do
- local path = fs.combine(dir, dateien[i])
- if fs.isDir(path) then
- if (dateien[i] ~= "rom") and (dateien[i] ~= "PSAV") and (dateien[i] ~= "PSAVbackup") then
- ReadDir(path)
- end
- end
- check(path)
- end
- end
- --------
- --MAIN--
- --------
- --Liest mgl. probleme ein
- probtxt = fs.open("/PSAV/problems.txt", "r")
- zeile = probtxt.readLine()
- repeat
- table.insert(probinhalt, zeile)
- zeile = probtxt.readLine()
- until zeile == nil
- term.clear()
- term.setCursorPos(1,1)
- ReadDir("/")
- --nochmal Problem Anzahl anzeigen...
- if problem == 1 then
- print(problem.." problem found!")
- else
- print(problem.." problems found!")
- end
- term.setTextColour( colors.yellow )
- print("Waiting for Mouseclick")
- os.pullEvent("mouse_click")
- shell.run("/PSAV/details")
Advertisement
Add Comment
Please, Sign In to add comment