diff --git a/core.lua b/core.lua index 9e10f70..fab84ac 100644 --- a/core.lua +++ b/core.lua @@ -98,8 +98,17 @@ function Core:download(file) return false, "Invalid type: "..textutils.serialiseJSON(data) end + if fs.exists(file) then + fs.delete(file); + end + local fileStream = io.open(file, "w"); - fileStream:write(data.fileContent); + + if not fileStream then + return false, "Failed to open fileStream" + end + + fileStream:write(data.data); fileStream:close(); return true, "Success" diff --git a/downloadCore.lua b/downloadCore.lua new file mode 100644 index 0000000..66f4355 --- /dev/null +++ b/downloadCore.lua @@ -0,0 +1,9 @@ +require("core") + +local core = Core.new(); + +core:connect(); + +core:download("core.lua"); + +core:disconnect(); \ No newline at end of file