Advertisement
osmarks

PotatOS Disk Upgrade Utility

Jun 2nd, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. --[[
  2. PotatOS Tau has recently switched from a table format for disk signatures to a shiny, new hexadecimal one.
  3. Existing disks can be upgraded with this utility.
  4. ]]
  5.  
  6. local function hexize(sig)
  7.     local out = ""
  8.     for _, v in pairs(sig) do
  9.         out = out .. string.format("%.2x", v)
  10.     end
  11.     return out
  12. end
  13.  
  14. local function fwrite(n, c)
  15.     local f = fs.open(n, "w")
  16.     f.write(c)
  17.     f.close()
  18. end
  19.  
  20. local function fread(n)
  21.     local f = fs.open(n, "r")
  22.     local out = f.readAll()
  23.     f.close()
  24.     return out
  25. end
  26.  
  27. print "Place the disk to be upgraded in a connected disk drive."
  28. local _, side = os.pullEvent "disk"
  29. local path = fs.combine(disk.getMountPath(side), "signature")
  30. if not fs.exists(path) then error "Inserted disk does not contain a signature!" end
  31.  
  32. fwrite(path, hexize(textutils.unserialize(fread(path))))
  33. print "Done!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement