Advertisement
TheRockettek

fsRedirect

Jan 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. local fsredirectPath = "/"
  2. local fsapi = {}
  3. for i,k in pairs(_G.fs) do
  4.     fsapi[i] = k
  5. end
  6. _G.fs.getPath = function()
  7.     return fsredirectPath
  8. end
  9. _G.fs.setPath = function(path)
  10.     if not path then
  11.         error("Expected string")
  12.     end
  13.     local path = tostring(path)
  14.     if not fs.exists(path) then
  15.         error("Folder does not exist")
  16.     end
  17.     fsredirectPath = path
  18. end
  19.  
  20. -- Replacing old api.
  21. _G.fs.list = function(path)
  22.     return fsapi.list(fsredirectPath .. path)
  23. end
  24. _G.fs.exists = function(path)
  25.     return fsapi.exists(fsredirectPath .. path)
  26. end
  27. _G.fs.isDir = function(path)
  28.     return fsapi.isDir(fsredirectPath .. path)
  29. end
  30. _G.fs.isReadOnly = function(path)
  31.     return fsapi.isReadOnly(fsredirectPath .. path)
  32. end
  33. _G.fs.getDir = function(path)
  34.     return fsapi.getDir(fsredirectPath .. path)
  35. end
  36. _G.fs.getName = function(path)
  37.     return fsapi.getName(fsredirectPath .. path)
  38. end
  39. _G.fs.getSize = function(path)
  40.     return fsapi.getSize(fsredirectPath .. path)
  41. end
  42. _G.fs.getDrive = function(path)
  43.     return fsapi.getDrive(fsredirectPath .. path)
  44. end
  45. _G.fs.getFreeSpace = function(path)
  46.     return fsapi.getFreeSpace(fsredirectPath .. path)
  47. end
  48. _G.fs.makeDir = function(path)
  49.     return fsapi.makeDir(fsredirectPath .. path)
  50. end
  51. _G.fs.move = function(patha,pathb)
  52.     return fsapi.move(fsredirectPath .. patha,fsredirectPath .. pathb)
  53. end
  54. _G.fs.copy = function(patha,pathb)
  55.     return fsapi.copy(fsredirectPath .. patha,fsredirectPath .. pathb)
  56. end
  57. _G.fs.delete = function(path)
  58.     return fsapi.delete(fsredirectPath .. path)
  59. end
  60. _G.fs.combine = function(path,localpath)
  61.     return fsapi.combine(fsredirectPath .. path,fsredirectPath .. localpath)
  62. end
  63. _G.fs.open = function(path,mode)
  64.     return fsapi.combine(fsredirectPath .. path,mode)
  65. end
  66. _G.fs.complete = function(path,location)
  67.     return fsapi.complete(fsredirectPath .. path,location)
  68. end
  69. _G.fs.restore = function()
  70.     _G.fs = fsapi
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement