Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server (Source Computer) Code
- local modem = peripheral.wrap("left") -- Adjust as necessary to match your modem's side
- modem.open(123) -- Open a channel for communication
- local function sendDirectory(path)
- local files = fs.list(path)
- for _, file in ipairs(files) do
- local fullPath = path .. "/" .. file
- if fs.isDir(fullPath) then
- modem.transmit(123, 123, {type="dir", name=file})
- sendDirectory(fullPath)
- else
- local fileContent = fs.read(fullPath)
- modem.transmit(123, 123, {type="file", name=file, content=fileContent})
- end
- end
- end
- while true do
- local event, side, channel, replyChannel, message = os.pullEvent("modem_message")
- if channel == 123 and message == "GET_DISK" then
- sendDirectory("/disk/")
- modem.transmit(123, 123, {type="end"})
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement