Advertisement
DOGGYWOOF

Doggy OS Update installer

Mar 14th, 2024
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. -- Function to receive files from the client
  2. local function receiveFilesFromClient()
  3. local senderID, _, _, _, message = os.pullEvent("modem_message")
  4. local deviceID = tostring(senderID)
  5. local files = message[1]
  6.  
  7. -- Assuming each file is represented as a string
  8. for _, file in ipairs(files) do
  9. local fileContent = fs.open(file, "r")
  10. if fileContent then
  11. local content = fileContent.readAll()
  12. fileContent.close()
  13. local savePath = "/disk/update_" .. deviceID .. "/" .. fs.getName(file)
  14. local saveFile = fs.open(savePath, "w")
  15. saveFile.write(content)
  16. saveFile.close()
  17. print("Received file: " .. savePath)
  18. else
  19. print("Failed to open file: " .. file)
  20. end
  21. end
  22. end
  23.  
  24. -- Main loop to continuously receive files
  25. while true do
  26. receiveFilesFromClient()
  27. end
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement