This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simple question about fopen "a" option

Hi

I've search the website and the manuals and can't get an answer, i would phone up but as it's out of hours i thought i'd ask here first.

I am using RTL-ARM and the FlashFS supplied by Keil on external Flash chip in my system.

I can't determine from the documentaion if a file can be modified eg. opened with fout=fopen(filename,"a") changing the file pointer with fseek and then overwriting data using fwrite?

Thanks
Luke

  • No, this is not supported for embedded flash devices. RTL-ARM FlashFS is a simple file system and does not allow rw file access. It also does not allow modifying existing file data.

    A possible workaround is to to open another file and copy original and modified data to a new file.

    Franc

  • Thank you for clarifing this.
    i will work to implement your suggestion.

    one more question:
    When you say the filesystem does not allow RW access can i have 1 file open twice (1) both read only ie. 2 function accessing different parts of the file (2) 1 read 1 write ie. a function reading data from file and another appending data to the end of the file?

    Luke

  • You can have one file opened twice for read. However the same file opened twice first for read and second for write is not supported. Second call to fopen() for write will fail. This is because a file allocation information is simplified to keep FlashFS simple and allow fast file access, but on the other hand this does not allow such requests.

    Franc

  • Thank you

    Now i know the nature of the beast i can work with rather than against it.

    your assistant is much appreciated.