Advertisement
programcreator

FSH test 1

May 28th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --[[
  2.     VFS helper and moumting manager
  3.     Author: Wassil Janssen a.k.a. Creator
  4. ]]--
  5.  
  6. --Variables
  7. local mounts = {}
  8.  
  9. --Functions
  10. function mount(destination,path)
  11.     local tabl,dir = makeTable(destination,mounts)
  12.     print(tabl)
  13.     print(dir)
  14. end
  15.  
  16. local function makeTable(path,tabl)
  17.     if type(path) ~= "string" then error("Expected string, got "..type(path).."!",2) end
  18.     if type(tabl) ~= "table" then error("Expected table, got "..type(path).."!",2) end
  19.     path = fs.combine("",path)
  20.     local first = path:sub(1,path:find("/") or -1)
  21.     if not tabl[first] then tabl[first] = {} end
  22.     if first == path then
  23.         return tabl, first
  24.     else
  25.         return makeTable(path:sub(path:find("/")+1,-1),tabl[first])
  26.     end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement