Simon, Sorry it was clearly my fault. I was quite sure I'm using the openBinaryFile, while I was using openFile. Turned out after several more hours of tough debugging. BTW, wouldn't it be better if there were text/binary output functions instead of text/binary files? It makes sense to output strings in text mode, but arrays of Word8 in binary mode (my case). It looks at least strange, that while writing the array with 0xA the values are written as 0xD 0xA (text conversion). Regards, Mike
-------------------------------------------------------------------------------- ïï: Simon Marlow [mailto:[EMAIL PROTECTED] ïïïïïïïïïï: ïï, 15.06.2004 15:06 ïïïï: Mike Aizatsky; [EMAIL PROTECTED] ïïïï: RE: Strange problems with binary file output: result of incorrect size On 11 June 2004 14:46, Mike Aizatsky wrote: > Hello, > > I'm having strange problems with binary file output. In my > application I'm preparing the [Word8], then doing just 4 operations: > > 1. openBinaryFile > 2. newListArray from my list > 3. hPutArray > 4. file close > > Everything works ok till I change one function deep in computational > code. The change is like this one: > was: > foo :: ...... -> Double > foo params = result where ..... > > now: > > foo :: ...... -> Double > foo params = result*g(params) where ..... > > After the change, while the list is of the same size (I've traced the > list size and array size), the output is of different size! While the > array has 849,352 the resulting file is 10K larger. I've tried to > write the elements from array using hPutChar instead of hPutArray. > The file still has the size, not equal to array size. > > Unfortunately, any attempts to product small self-contained example > have failed. But I can easily reproduce it in my app. Any ideas what > should I try to nail down the problem? May this be a buffering issue? > Can I turn buffers off/make them larger? Try turning off buffering with hSetBuffering. Nevertheless, we probably need a repeatable example in order to track down the bug. 10k larger is more than the size of the buffer, so it's possible something else is going on. What do the contents of the file look like? Is it padded with zeroes? Cheers, Simon _______________________________________________ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
