-
Notifications
You must be signed in to change notification settings - Fork 51
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] ff_truncate documentation inadequate #54
Comments
Hello @carlk3, Apologies for the late reply. We somehow missed looking at the issues in this repository. It seems that you are correct about ff_truncate opening the file in append mode - which does allow reading and writing. We will update the documentation to say that. We are aware that it is non-standard for ff_truncate to return a pointer to an opened file. It was done because when ff_truncate fails it is unclear by the return code whether the file is left in an open state or not. Returning file pointer gets around that issue. Tagging @htibosch here so that he can also chime in and correct me if I am wrong. Thanks, |
Hi, On Thu, Feb 15, 2024 at 12:10 PM Aniruddha Kanhere [email protected] wrote:
This issue: [DOC] ff_fseek() documentation inadequate Append mode is weird. In append mode, output to files is always appended sequentially to the end of the file, regardless of the file position. However, there should be a way to move the file position to the absolute beginning of the file for reading, but there is not. The point of this Issue is that there are major differences in the behavior if
|
ff_truncate() returns a file handle: that was done because it is handy for many users. Seek past the end of file: I didn't want to implement that because it is error prone.
I would classify that as a bug, it is not what you want. I'm sorry for being brief. |
Updated the website to include behaviour and restrictions of the FreeRTOS-specific ff_truncate() function. |
Describe the issue
Please describe the issue and expected clarification in concise language.
ff_truncate has important restrictions that are not mentioned. Since this behavior is non-standard, I believe it would be best to state the restrictions rather than leave them unsaid. They might come as a surprise to someone used to, say, POSIX.
ff_truncate says that it " Opens a file for writing...", but technically, that is not true. It actually opens a file for append, as in ff_fopen pcMode "a" or "a+". Therefore, because of the limitations of fseek and ff_rewind, if the file already exists and it is opened with ff_truncate it is impossible to move the file position to the absolute beginning of the file or to any position between there and the end of the preexisting file.
Also, it's non-standard that ff_truncate returns a pointer to an opened file. See truncate or File Size.
Reference
Please attach the URL at which you are experiencing the issue.
https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/stdio_API/ff_truncate.html
Screenshot
If applicable, please attach screenshot.
Browser
The text was updated successfully, but these errors were encountered: