Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local repoID = 0
- function init(side, repo)
- rednet.open(side)
- repoID = repo
- end
- function fileToString(path)
- local file = fs.open(path, "r")
- local content = file.readAll()
- local str = textutils.serialize(content)
- return str
- end
- function sendFile(path)
- local code = fileToString(path)
- local to = repoID
- rednet.send(to, "cfile "..path)
- rednet.send(to, code)
- end
- function sendFileRequest(path)
- rednet.send(repoID, "request "..path)
- end
- function getFile(path)
- sendFileRequest(path)
- local id, msg, distance = rednet.receive()
- local handle = fs.open(path, "w")
- local strx = string.gmatch(msg, "ass!s!123_ADADkpc8[(1O")
- if strx == nil then
- print("Received file "..path.." successfully!")
- else
- print("You do not have permissions to access this file!")
- end
- handle.write(textutils.unserialize(msg))
- handle.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement