Silverbullets

(ComputerCraft) Installation program for disks

Aug 8th, 2015
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. --Installation program for moving things to and from a disk.
  2. --Made by xXPteranoXx
  3. --Run from command line
  4.  
  5. arg = {...}
  6.  
  7. baseDir = ""
  8.  
  9. function setBaseDir(dir)
  10.   baseDir = dir
  11. end
  12.  
  13. function getBaseDir()
  14.   return baseDir
  15. end
  16.  
  17. function copyFiles(fromDir)
  18.   local fileTable = fs.list(tostring(fromDir))
  19.   local toDir = "installedPrograms/"
  20.   if not fs.isDir(toDir) then
  21.     print("Created the directory "..toDir)
  22.     fs.makeDir(toDir)
  23.   end
  24.   local fCount = 0
  25.   for i,v in pairs(fileTable) do
  26.     print("Moving "..v.." to "..toDir)
  27.     fs.copy(tostring(fromDir.."/"..v), toDir..v)
  28.     fCount = fCount + 1
  29.     print(table.getn(fileTable) - fCount.." files remaining")
  30.   end
  31. end
  32.  
  33. function main()
  34. --fromDisk is going to be a pretty standard thing.
  35. --The program by default will copy over from the disk
  36. --What is there.
  37. --Network installs will possibly come later.
  38. --read in our args list
  39.   if table.getn(arg) == 0 then
  40.     print("Please enter a directory to install from!\n")
  41.     return
  42.   end
  43.   copyFiles(tostring(arg[1]))
  44. end
  45.  
  46. main()
Advertisement
Add Comment
Please, Sign In to add comment