MudkipTheEpic

HideFile API [WIP]

Feb 3rd, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. local fs2 = fs2 or {}
  2. local hidetable = hidetable or {}
  3. local authlist = {shell.getRunningProgram() = true} -- Edit this to contain your authorized programs.
  4. local fs2.open = fs2.open or fs.open
  5. local fs2.delete = fs2.delete or fs.delete
  6. local fs2.list = fs2.list or fs.list
  7. local fs2.copy = fs2.copy or fs.copy
  8. local fs2.move = fs2.move or fs.move
  9. local fs2.ioO = fs2.ioO or io.open
  10. local function isallowed(file)
  11. for k,v in pairs(authlist) do
  12. if v == file then return true end
  13. end
  14. return false
  15. end
  16. local function ishidden(filename)
  17. if hidetable[filename] then return true else return false end
  18. end
  19. fs.hide = function(filename)
  20. if not isallowed(shell.getRunningProgram()) then
  21. error("attempt to call nil", 2)
  22. return nil
  23. else
  24. if not hidetable[filename] then
  25. hidetable[filename] = true
  26. return true
  27. end
  28. end
  29. fs.show = function(filename)
  30. if not isallowed(shell.getRunningProgram()) then
  31. error("attempt to call nil", 2)
  32. return nil
  33. else
  34. if hidetable[filename] then
  35. hidetable[filename] = nil
  36. return true
  37. end
  38. end
  39. end
  40. -- Rest to work on later, gonna work on other projects...
Advertisement
Add Comment
Please, Sign In to add comment