Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the blocked operations
- local blockedOperations = {
- rootDeletion = "/",
- osDeletion = "/disk/os/",
- packagesDeletion = "/disk/packages/",
- bootDeletion = "/disk/boot/",
- bootloaderDeletion = "/disk/bootloader/",
- errorDeletion = "/disk/error/",
- osCopying = "/disk/os/",
- bootloaderCopying = "/disk/bootloader/",
- bootCopying = "/disk/boot/",
- errorCopying = "/disk/error/",
- editCommand = "edit",
- }
- -- Function to check if a line contains blocked code
- local function isBlocked(line)
- for _, op in pairs(blockedOperations) do
- if string.find(line, op, 1, true) then
- return true
- end
- end
- return false
- end
- -- Function to check for blocked code in a file
- local function checkFile(filePath)
- local file = fs.open(filePath, "r")
- if not file then
- return -- Couldn't open file
- end
- local line
- repeat
- line = file.readLine()
- if line and isBlocked(line) then
- file.close()
- return true
- end
- until not line
- file.close()
- return false
- end
- -- Main loop to check files every 2 seconds
- while true do
- -- Check for blocked code in each file in /disk/packages
- local files = fs.list("/disk/packages")
- for _, file in ipairs(files) do
- local filePath = "/disk/packages/" .. file
- if fs.isDir(filePath) then
- -- Skip directories
- elseif checkFile(filePath) then
- -- Blocked code detected
- shell.run("fg", "/disk/error/rt-error")
- fs.delete(filePath) -- Delete the file
- end
- end
- sleep(2) -- Sleep for 2 seconds
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement