Advertisement
Redxone

Computercraft - Virtual Hard Disk Creator

Jul 20th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. --]] get file system [[--
  2. local tArgs = { ... }
  3. local _system = {}
  4. if(fs.isDir("vhd") and tArgs ~= "vhd")then error("Please Unload VHD Before Continuing.") end
  5. -- ]] precaution for dirs [[ --
  6. function getFileCont(dr)
  7.     for k, v in pairs(fs.list(dr)) do
  8.      
  9.       if(fs.isDir(dr.."/"..v) and not fs.isReadOnly(dr.."/"..v))then
  10.         getFileCont(dr..v.."/")
  11.       else
  12.       print(dr..v)
  13.         if(not fs.isReadOnly(dr..v))then
  14.           f = fs.open(dr..v,"r")
  15.          _system[dr..v] = {content = f.readAll()}
  16.          f.close()
  17.         end
  18.       end
  19.     end
  20. end
  21.  
  22. if(not tArgs[2])then
  23.     getFileCont("")
  24. else
  25.     getFileCont(tArgs[2].."/")
  26. end
  27.  
  28. if(#tArgs < 1)then error("Ussage: createhdd <export file> [optional]<directory>") end
  29. local exp = tArgs[1]
  30.  
  31. f = fs.open(exp,"w")
  32. f.write(textutils.serialize(_system))
  33. f.close()
  34. print("System Exported To: "..exp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement