I'm a complete newbie in Lua and i've stumbled upon a problem i don't understand.
So what i'm trying to do is open a file, read the data and save it into a different file with a different name.
Here is the code
local infile = io.open(folder..'/'..f, "r")
local instr = infile:read("*all")
infile:close()
local outfile = io.open(folder..'/'..newName, "w")
outfile:write(instr)
outfile:close()
The result i get is a Source file 288Kb and a Dest file 2Kb
So again, as i'm a newbie in Lua, the fact that the problem is in infile:read is a wild guess for me, but the way i see it, it's either infile:read or outfile:write.
UPD: The content is absolutely arbitrary, which implies special symbols occur.
Thank you in advance,
Regards!
I've made it work by opening the in- and output file in binary mode by adding flag b in the io.open call., so the code I have now is
local infile = io.open(folder..'/'..f, "rb")
local instr = infile:read("*all")
Log(instr)
infile:close()
local outfile = io.open(folder..'/'..newName, "wb")
outfile:write(instr)
outfile:close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With