Make File::rewindDirectory reference demo code more clear#118
Merged
per1234 merged 2 commits intoarduino-libraries:masterfrom Apr 25, 2022
per1234:improve-rewinddirectory-ref-code
Merged
Make File::rewindDirectory reference demo code more clear#118per1234 merged 2 commits intoarduino-libraries:masterfrom per1234:improve-rewinddirectory-ref-code
File::rewindDirectory reference demo code more clear#118per1234 merged 2 commits intoarduino-libraries:masterfrom
per1234:improve-rewinddirectory-ref-code
Conversation
karlsoderby
approved these changes
Apr 25, 2022
The reference page for `File::rewindDirectory` provides a sketch demonstrating its usage. This code calls the function after iterating over each directory on the card. This would be necessary if the `printDirectory` function was configured to iterate over that directory multiple times, but it is not. So the calls are redundant. Moving the call to the `setup` function has the following benefits: - Makes the use of the function more prominent. The reader can get an overview of what the program is doing without delving into the `printDirectory` function - Avoids the misconception that it is required to call the function recursively as was done before
`File::rewindDirectory` is used to reset the current position in the file system. Previously, the file structure was only iterated over once, in which case rewinding is not necessary and will have no observable effect. In the following sequence, it is necessary and does have an observable effect: 1. Iterate over file structure using `File::openNextFile` 2. Reset current position using `File::rewindDirectory` 3. Iterate over file structure using `File::openNextFile` The reader can simply remove the `File::rewindDirectory` call from the program that follows this sequence for a clear demonstration of its purpose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reference page for
File::rewindDirectoryprovides a sketch demonstrating its usage.Feedback was received that the code did not clearly demonstrate the use and effect of the function: arduino/Arduino#11734
@PaulStoffregen suggested several changes to improve on that situation. An atomic subset of those are proposed here:
File::rewindDirectory: 615568fResolves (partially) arduino/Arduino#11734