Advertisement
LDDestroier

prot - Stupid Lua Program

Feb 23rd, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. function displayHelp()
  2.     print("prot <filename>")
  3. end
  4.  
  5. tArg = {...}
  6.  
  7. function doIt()
  8.     fileName = tArg[1]
  9.     if protectedFiles == nil then
  10.         protectedFiles = {}
  11.     end
  12.     file = fs.open(fileName, "a")
  13.     table.insert(protectedFiles, fileName)
  14.     fs.open = function(path, mode)
  15.         for a = 1, #protectedFiles do
  16.             if mode == "w" or mode == "wb" or mode == "a" then
  17.                 if string.find(protectedFiles[a], path) ~= nil then
  18.                     return false
  19.                 else
  20.                     oldFsOpen(path, mode)
  21.                 end
  22.             else
  23.                 oldFsOpen(path, mode)
  24.             end
  25.         end
  26.     end
  27. end
  28.  
  29. if tArg[ 1 ] == nil then
  30.     displayHelp()
  31.     return false
  32. else
  33.     doIt()
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement