Advertisement
PaymentOption

CC Protect Startup

Feb 11th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local FILE_TO_PROTECT  = shell.resolve ("/startup")
  2. local old_fsOpen       = _G["fs"]["open"]
  3. local old_fsDelete     = _G["fs"]["delete"]
  4. local old_fsIsReadOnly = _G["fs"]["isReadOnly"]
  5.  
  6. -- Override of fs.open.
  7. _G["fs"]["open"] = function (path, mode)
  8.     path = shell.resolve (path)
  9.     mode = string.lower (mode)
  10.    
  11.     if path == FILE_TO_PROTECT then
  12.         return nil
  13.     end
  14.    
  15.     return old_fsOpen (path, mode)
  16. end
  17.  
  18. -- Override of fs.delete.
  19. _G["fs"]["delete"] = function (path)
  20.     path = shell.resolve (path)
  21.    
  22.     if path == FILE_TO_PROTECT then
  23.         -- Mimick error.
  24.         return shell.run ("delete", "/rom/")
  25.     end
  26.    
  27.     return old_fsDelete (path)
  28. end
  29.  
  30. -- Override of fs.isReadOnly.
  31. _G["fs"]["isReadOnly"] = function (path)
  32.     path = shell.resolve (path)
  33.    
  34.     if path == FILE_TO_PROTECT then
  35.         return true
  36.     end
  37.    
  38.     return old_fsIsReadOnly (path)
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement