fx_file_seek, not working as expected in BSP 1.7.0


I have a very simple problem with fx_file_seek. I have to create a file and write contents to the end of the file, at the offset 944704 bytes.

So I create the file, open the file and write something at the beginning, fine.  

Then open the file again seek to position 944704 and write, but the data is placed next to the previous written data, why?

It is not possible to use fx_file_seek to 'inflate' a file and write a the end?

Currently using 1.7.0 BSP.

Thank you in advance.


  • No. It doesn't work that way - from the FileX Users Guide...

    • byte_offset: Desired byte offset in file. A value of zero will position the read/write pointer at the beginning of the file, while a value greater than the file's size will position the read/write pointer at the end of the file.

    The semantics you describe is similar to the Posix (Linux) lseek - if you position to 944704, past the end of the file, it will still write to the end of the end of file (it is is smaller), but reads for the "gap" values will return 0 always. An interesting behavior.