Advertisement
DOGGYWOOF

Doggy OS install server

Jul 27th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. -- Server (Source Computer) Code
  2. local modem = peripheral.wrap("left") -- Adjust as necessary to match your modem's side
  3. modem.open(123) -- Open a channel for communication
  4.  
  5. local function sendDirectory(path)
  6. local files = fs.list(path)
  7. for _, file in ipairs(files) do
  8. local fullPath = path .. "/" .. file
  9. if fs.isDir(fullPath) then
  10. modem.transmit(123, 123, {type="dir", name=file})
  11. sendDirectory(fullPath)
  12. else
  13. local fileContent = fs.read(fullPath)
  14. modem.transmit(123, 123, {type="file", name=file, content=fileContent})
  15. end
  16. end
  17. end
  18.  
  19. while true do
  20. local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
  21. if channel == 123 and message == "GET_DISK" then
  22. sendDirectory("/disk/")
  23. modem.transmit(123, 123, {type="end"})
  24. end
  25. end
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement