Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function listen()
- print("Listening for files...")
- while true do
- id, message, info = rednet.receive()
- local breakWhenDone = true
- if message == "dir" then
- fs.makeDir(info[1])
- breakWhenDone = false
- elseif message == "recieve"
- file = fs.open(info[1], "w")
- file.write(info[2])
- file.close()
- print("File Received!")
- if breakWhenDone then
- break
- end
- elseif message == "stop" then
- if not breakWhenDone then
- breakWhenDone = true
- break
- end
- end
- end
- end
- function send(f)
- if fs.isDir(f) then
- print("Sending Directory...")
- local files = fs.list(f)
- rednet.broadcast("dir")
- else
- print("Sending File...")
- file = fs.open(tostring(f), "r")
- local name = tostring(f)
- local content = file.readAll()
- info = {name, content}
- rednet.broadcast("receive", info)
- print("File Sent!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement