Advertisement
Techzune

rDisk - Disk Drive Utility

Jan 18th, 2012
1,506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.38 KB | None | 0 0
  1. --[[
  2. Program Name: rDisk - Disk Drive Utility
  3. Created By: Techzune
  4. Version: 0.5
  5. Description: Utilities for disk drives.
  6. Utilities Included:
  7. *Transfer Files
  8. *Format Disks!
  9. *Rename Disks
  10.  
  11. ! = Buggy
  12.  
  13. DO NOT REMOVE THIS! Thank You!
  14. Operon Technologies - ComputerCraft and Lua
  15. --]]
  16.  
  17. version = 0.5
  18.  
  19.  
  20. running = true
  21.  
  22. function sprint(text)
  23.   textutils.slowPrint(text)
  24. end
  25. function clear()
  26.   term.clear()
  27.   term.setCursorPos(1,1)
  28.   print("rDisk | Disk Drive Utility v" .. version)
  29.   print("--------------------------")
  30.   print("")
  31. end
  32. function transfer()
  33.   clear()
  34.   sprint("Which side do you want to transfer from?")
  35.   print("front, back, left, right, top, bottom")
  36.   fside = io.read()
  37.   if disk.isPresent(fside) then
  38.     print("")
  39.     sprint("Please enter the path to the file.")
  40.     fpath = io.read()
  41.     fpath = disk.getMountPath(fside) .. "/" .. fpath
  42.     if fs.exists(fpath) then
  43.       clear()
  44.       sprint("What side is the destination?")
  45.       print("font, back, left, right, top, bottom")
  46.       dside = io.read()
  47.       if disk.isPresent(dside) then
  48.         print("")
  49.         sprint("What would you like to name this file?")
  50.         fname = io.read()
  51.         clear()
  52.         sprint("Transfering File - Please Wait...")
  53.         dpath = disk.getMountPath(dside) .. "/" .. fname
  54.         fs.copy(fpath, dpath)
  55.         print("")
  56.         sprint("File Transfer Complete")
  57.         sleep(2)
  58.         term.clear()
  59.         term.setCursorPos(1,1)
  60.       else
  61.         print("Error: Disk Not Found")
  62.         sleep(2)
  63.         transfer()
  64.       end
  65.     else
  66.       print("Error: File Not Found")
  67.       sleep(2)
  68.       transfer()
  69.     end
  70.   else
  71.     print("Error: Disk Not Found")
  72.     sleep(2)
  73.     transfer()
  74.   end
  75. end
  76. function formatdisk()
  77.   clear()
  78.   sprint("What side do you want to format?")
  79.   print("front, back, left, right, top, bottom")
  80.   foside = io.read()
  81.   if disk.isPresent(foside) then
  82.     print("")
  83.     sprint("Are you sure you want to format this disk?")
  84.     sprint("All Data Will Be Erased!")
  85.     print("Y or N")
  86.     fodecision = io.read()
  87.     if fodecision == "Y" or fodecision == "y" then
  88.       print("")
  89.       sprint("Formatting...")
  90.       folist = shell.resolve(disk.getMountPath(foside))
  91.       fodir = fs.list(folist)
  92.       for i, v in pairs(fodir) do
  93.         fs.delete(disk.getMountPath(foside) .. "/" .. v)
  94.         disk.setLabel(foside, "")
  95.       end
  96.     end
  97.   else
  98.     print("Error: Disk Not Found")
  99.     sleep(2)
  100.     formatdisk()
  101.   end
  102. end
  103. function renamedisk()
  104.   clear()
  105.   sprint("What side do you want to rename?")
  106.   print("front, back, left, right, top, bottom")
  107.   renside = io.read()
  108.   if disk.isPresent(renside) then
  109.     print("")
  110.     sprint("What would you like to name this floppy disk?")
  111.     renname = io.read()
  112.     disk.setLabel(renside, renname)
  113.   else
  114.     print("Error: Disk Not Found")
  115.     sleep(2)
  116.     renamedisk()
  117.   end
  118. end
  119. --Startup & Menus--
  120. function startup()
  121.   clear()
  122.   print("Please choose an option from the menu: ")
  123.   print("")
  124.   print("[1] Transfer/Copy Files Between Floppy Disks")
  125.   print("[2] Format a Floppy Disk")
  126.   print("[3] Rename a Floppy Disk")
  127.   print("[4] Exit")
  128.   startupc = io.read()
  129.   if startupc == "1" then
  130.     transfer()
  131.   elseif startupc == "2" then
  132.     formatdisk()
  133.   elseif startupc == "3" then
  134.     renamedisk()
  135.   elseif startupc == "4" then
  136.     print("Goodbye!")
  137.   end
  138. end
  139. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement