Posted 06 September 2012 - 07:20 PM
I have been trying to create function for reading and writing binary from a file to a string and back. similar to the readAll function but without changing the data as it is read. the normal readAll causes the File to be corrupted as it is loaded this happened because the binary doesn't match a character so the computer corrects this error and in doing so corrupted data in transit.
to work with raw unaltered data the read ("rb") and write ("wb") binary options can be used with fs.open.
the bellow code will load a file into a string binary and all . my problem in the write function I cant work out how to make it function. It keeps giving an odd error [binReadWrite.lua:27: bad argument: int expected, got table]
I know there are other ways to read and write from a file but for working with MIDI file it has to be binary.
http://pastebin.com/1NbdZpS7
If someone would be so kind as to explain writing binary to a file I would very much appreciate it.
to work with raw unaltered data the read ("rb") and write ("wb") binary options can be used with fs.open.
the bellow code will load a file into a string binary and all . my problem in the write function I cant work out how to make it function. It keeps giving an odd error [binReadWrite.lua:27: bad argument: int expected, got table]
I know there are other ways to read and write from a file but for working with MIDI file it has to be binary.
http://pastebin.com/1NbdZpS7
If someone would be so kind as to explain writing binary to a file I would very much appreciate it.