Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Error in ff_fopen() documentation #52

Closed
carlk3 opened this issue Nov 8, 2023 · 7 comments
Closed

[DOC] Error in ff_fopen() documentation #52

carlk3 opened this issue Nov 8, 2023 · 7 comments

Comments

@carlk3
Copy link
Contributor

carlk3 commented Nov 8, 2023

Describe the issue
Please describe the issue and expected clarification in concise language.

At ff_fopen, pcMode, Letter "w", Mode, it says "Open a file for reading and writing." This in incorrect. It is only opened for writing. If you try to read, permission is denied.

Reference
Please attach the URL at which you are experiencing the issue.

https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/stdio_API/ff_fopen.html

Screenshot
If applicable, please attach screenshot.

Browser

  • Browser: [e.g. Chrome]
  • Version: [e.g. 80.0.3987.132]
@htibosch
Copy link
Contributor

@carlk3 wrote:

At ff_fopen, pcMode, Letter "w", Mode, it says "Open a file for reading and writing." This in incorrect. If you try to read, permission is denied.

Out of curiosity, I tried the same under Linux and Windows: both fseek() and fread() return zero when the files was created with the "w"-flag:

    FILE *fp = fopen (fname, "w");
    if (fp != NULL) {
        fprintf(fp, "Hello world\n");
        int rc = fseek (fp, 0, SEEK_SET);
        if (rc == 0) {
            char contents[ 32 ];
            rc = fread (contents, 1, sizeof contents - 1, fp);
        }
        fclose (fp);
    }

I also tried to create the file with "w+", that does allow to write and read from the same hand.e

So let's change the documentation:

-    Open a file for reading and writing. If the file ...
+    Open a file for writing. If the file ...

Thank for your suggestion!

@carlk3
Copy link
Contributor Author

carlk3 commented Nov 14, 2023

I also tried to create the file with "w+", that does allow to write and read from the same hand.e

Of course, "w+" is not explicitly documented, although "r+" is. Looking at the code for uint8_t FF_GetModeBits( const char * pcMode ) (in ff_file.c), apparently you can mix and match individual characters in the string and order is not important. So, "+" could be documented separately.

I have found that the pcMode string "rw" works well in this case.

@kar-rahul-aws
Copy link
Member

Hi @carlk3, thanks for catching this for us. The documentation should be updated shortly. Will close the issue once the pages are updated. We will be updating the content as @htibosch suggested for now.

@kar-rahul-aws
Copy link
Member

We have updated the content in the page

@AniruddhaKanhere
Copy link
Member

I cannot see the change on the official page: https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/stdio_API/ff_fopen.html.

Once that is fixed, the issue can be closed.

@moninom1
Copy link
Member

Thank you @AniruddhaKanhere for pointing it out, working on updating it the official page, will update once done.

@moninom1
Copy link
Member

moninom1 commented Apr 8, 2024

The change is updated on the official page, Hence closing the issue. Thank you

@moninom1 moninom1 closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants