Re: How to read binary file in Nim?

2019-08-18 Thread nnahito
Thank you for your reply! > Your buffer points to nothing, allocate an array[4, byte] and pass its > address to readBuffer. Oh I must allocate read buffer size...I see. > > For example this is how I read the first 6 bytes for a magic string for a > binary format. Thank you your sample code! I

Re: How to read binary file in Nim?

2019-08-18 Thread nnahito
Thank you for your reply! And thank you for your source code! I try to study by your code.

Re: How to read binary file in Nim?

2019-08-15 Thread mratsim
Your buffer points to nothing, allocate an `array[4, byte]` and pass its address to readBuffer. I suggest you use streams if you need to save your position/restart your processing. For example this is [how I read the first 6

Re: How to read binary file in Nim?

2019-08-15 Thread treeform
Here is my code that reads wave files: [https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim](https://github.com/treeform/euphony/blob/master/src/euphony/wav.nim) There i use newFileStream which makes reading binary files really easy. Just use readStr, readUint16, readUint32...

How to read binary file in Nim?

2019-08-15 Thread nnahito
I want to read binary file inNim-language. Because I want to work with WAV files. But I don't know how easy it is to read the first four bytes. This may be because I am not good at English. I wrote the following code. However, nil is displayed. var hFile = open("example.wav",