cp may work properly on large files now, previous method was a horrid hack

This commit is contained in:
Izaya 2017-09-23 19:16:34 +10:00 committed by Izaya
parent a6e6bb5f6b
commit e1f8f6697e
1 changed files with 6 additions and 1 deletions

View File

@ -237,7 +237,12 @@ function fs.cp(s,d)
local df = fs.open(d,"wb")
local sf = fs.open(s,"rb")
if df and sf then
fs.write(df,fs.readall(sf))
local c = ""
while true do
c=fs.read(sf,2048)
if not c then break end
fs.write(df,c)
end
fs.close(df)
fs.close(sf)
return true