Advertisement
DOGGYWOOF

RT for DOggy OS

Mar 15th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. -- Define the blocked operations
  2. local blockedOperations = {
  3. rootDeletion = "/",
  4. osDeletion = "/disk/os/",
  5. packagesDeletion = "/disk/packages/",
  6. bootDeletion = "/disk/boot/",
  7. bootloaderDeletion = "/disk/bootloader/",
  8. errorDeletion = "/disk/error/",
  9. osCopying = "/disk/os/",
  10. bootloaderCopying = "/disk/bootloader/",
  11. bootCopying = "/disk/boot/",
  12. errorCopying = "/disk/error/",
  13. editCommand = "edit",
  14. }
  15.  
  16. -- Function to check if a line contains blocked code
  17. local function isBlocked(line)
  18. for _, op in pairs(blockedOperations) do
  19. if string.find(line, op, 1, true) then
  20. return true
  21. end
  22. end
  23. return false
  24. end
  25.  
  26. -- Function to check for blocked code in a file
  27. local function checkFile(filePath)
  28. local file = fs.open(filePath, "r")
  29. if not file then
  30. return -- Couldn't open file
  31. end
  32.  
  33. local line
  34. repeat
  35. line = file.readLine()
  36. if line and isBlocked(line) then
  37. file.close()
  38. return true
  39. end
  40. until not line
  41.  
  42. file.close()
  43. return false
  44. end
  45.  
  46. -- Main loop to check files every 2 seconds
  47. while true do
  48. -- Check for blocked code in each file in /disk/packages
  49. local files = fs.list("/disk/packages")
  50. for _, file in ipairs(files) do
  51. local filePath = "/disk/packages/" .. file
  52. if fs.isDir(filePath) then
  53. -- Skip directories
  54. elseif checkFile(filePath) then
  55. -- Blocked code detected
  56. shell.run("fg", "/disk/error/rt-error")
  57. fs.delete(filePath) -- Delete the file
  58. end
  59. end
  60.  
  61. sleep(2) -- Sleep for 2 seconds
  62. end
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement