Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Program Name: rDisk - Disk Drive Utility
- Created By: Techzune
- Version: 0.5
- Description: Utilities for disk drives.
- Utilities Included:
- *Transfer Files
- *Format Disks!
- *Rename Disks
- ! = Buggy
- DO NOT REMOVE THIS! Thank You!
- Operon Technologies - ComputerCraft and Lua
- --]]
- version = 0.5
- running = true
- function sprint(text)
- textutils.slowPrint(text)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- print("rDisk | Disk Drive Utility v" .. version)
- print("--------------------------")
- print("")
- end
- function transfer()
- clear()
- sprint("Which side do you want to transfer from?")
- print("front, back, left, right, top, bottom")
- fside = io.read()
- if disk.isPresent(fside) then
- print("")
- sprint("Please enter the path to the file.")
- fpath = io.read()
- fpath = disk.getMountPath(fside) .. "/" .. fpath
- if fs.exists(fpath) then
- clear()
- sprint("What side is the destination?")
- print("font, back, left, right, top, bottom")
- dside = io.read()
- if disk.isPresent(dside) then
- print("")
- sprint("What would you like to name this file?")
- fname = io.read()
- clear()
- sprint("Transfering File - Please Wait...")
- dpath = disk.getMountPath(dside) .. "/" .. fname
- fs.copy(fpath, dpath)
- print("")
- sprint("File Transfer Complete")
- sleep(2)
- term.clear()
- term.setCursorPos(1,1)
- else
- print("Error: Disk Not Found")
- sleep(2)
- transfer()
- end
- else
- print("Error: File Not Found")
- sleep(2)
- transfer()
- end
- else
- print("Error: Disk Not Found")
- sleep(2)
- transfer()
- end
- end
- function formatdisk()
- clear()
- sprint("What side do you want to format?")
- print("front, back, left, right, top, bottom")
- foside = io.read()
- if disk.isPresent(foside) then
- print("")
- sprint("Are you sure you want to format this disk?")
- sprint("All Data Will Be Erased!")
- print("Y or N")
- fodecision = io.read()
- if fodecision == "Y" or fodecision == "y" then
- print("")
- sprint("Formatting...")
- folist = shell.resolve(disk.getMountPath(foside))
- fodir = fs.list(folist)
- for i, v in pairs(fodir) do
- fs.delete(disk.getMountPath(foside) .. "/" .. v)
- disk.setLabel(foside, "")
- end
- end
- else
- print("Error: Disk Not Found")
- sleep(2)
- formatdisk()
- end
- end
- function renamedisk()
- clear()
- sprint("What side do you want to rename?")
- print("front, back, left, right, top, bottom")
- renside = io.read()
- if disk.isPresent(renside) then
- print("")
- sprint("What would you like to name this floppy disk?")
- renname = io.read()
- disk.setLabel(renside, renname)
- else
- print("Error: Disk Not Found")
- sleep(2)
- renamedisk()
- end
- end
- --Startup & Menus--
- function startup()
- clear()
- print("Please choose an option from the menu: ")
- print("")
- print("[1] Transfer/Copy Files Between Floppy Disks")
- print("[2] Format a Floppy Disk")
- print("[3] Rename a Floppy Disk")
- print("[4] Exit")
- startupc = io.read()
- if startupc == "1" then
- transfer()
- elseif startupc == "2" then
- formatdisk()
- elseif startupc == "3" then
- renamedisk()
- elseif startupc == "4" then
- print("Goodbye!")
- end
- end
- startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement