Hello,
I’m going nuts here trying to read a file (an image generated by display.save() ) and write a copy, but both file:read() and io.read() stop at the first SUB character of the file.
I suppose this is intended behavior, but how should I go about it then?
Reading binary (“rb”) doesn’t stop at SUB but produces a different/corrupt file after writing.
Code:
-- Get image path local path = system.pathForFile( "screen\_to\_share.jpg", system.TemporaryDirectory ); -- Read string local fileHandle, err = io.open( path ) local destHandle = io.open( system.pathForFile( "sky.jpg", system.TemporaryDirectory ), "w" ) destHandle:write( fileHandle:read( "\*a" ) ) destHandle:close() fileHandle:close() -- Read binary local fileHandle, err = io.open( path, "rb" ) local destHandle = io.open( system.pathForFile( "sky2.jpg", system.TemporaryDirectory ), "w+" ) destHandle:write( fileHandle:read( "\*a" ) ) destHandle:close() fileHandle:close()
Help, thanks!