You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In tinydir_open_sorted, a first pass is used to count the number of files, then a second pass actually reads the file info. In between the two passes, tinydir closes and reopens the dir.
This is unnecessary with dirent; there's the rewinddir function which allows going back to the first file. This would also eliminate a race condition where the directory may have changed between the two passes.
Not sure if there's an equivalent for Windows.
The text was updated successfully, but these errors were encountered:
What about malloc() a small block of memory (maybe size * 12, I guess), and realloc() another block when needed? Will need only one-pass. Might be slower, but safer about race condition.
There could be a balance between safety and efficiency.
I tried a doubling realloc implementation before but counting in two passes was faster on a folder with 10000 items. Anyway rewinddir should be both fast and safe. See #6
In tinydir_open_sorted, a first pass is used to count the number of files, then a second pass actually reads the file info. In between the two passes, tinydir closes and reopens the dir.
This is unnecessary with dirent; there's the
rewinddir
function which allows going back to the first file. This would also eliminate a race condition where the directory may have changed between the two passes.Not sure if there's an equivalent for Windows.
The text was updated successfully, but these errors were encountered: