我正在使用以下程序複製另一個文件。我經常看到源和目標不完全相同(md5sum不同)。下面的代碼有什麼問題嗎?LUA副本問題
local size = 2^13 -- good buffer size (8K)
local params = {...}
local srcfile = params[1]
local outfile = params[1] .. "_copy"
print (srcfile)
print (outfile)
local inf = io.open(srcfile, "r")
local of = io.open(outfile, "w")
while true do
local block = inf:read(size)
print(size)
if not block then break end
of:write(block)
end
inf:close()
of:close()
感謝, GL
放棄循環,只使用'of:write(inf:read(「* a」))''。 – lhf