320x200 OpenComputers video encoder
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cpdrive.lua 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --[[
  2. cpdrive: unmanaged drive copy tool
  3. Copyright (c) 2018 asie
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. this software and associated documentation files (the "Software"), to deal in
  6. the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. ]]
  20. local args = {...}
  21. local component = require("component")
  22. local drive = component.drive
  23. print("Copying \"" .. args[1] .. "\" to drive...")
  24. local file = io.open(args[1], "rb")
  25. local d = true
  26. local sec = 0
  27. while d do
  28. local f = file:read(512)
  29. if f == nil then d = false
  30. else
  31. sec = sec + 1
  32. drive.writeSector(sec, f)
  33. if ((sec % 16) == 0) then
  34. print("Sector " .. sec)
  35. end
  36. end
  37. end
  38. print("Copied!")