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
When MOS makes a call to the faffs's f_findfirst function, passing in a pattern of "" (i.e. an empty string) and providing a path to a valid directory, the expected behaviour from fatfs is to return FR_OK, but leave the file info object with an empty filename, as there was not actually a file to match against
The emulator however will return the first file it finds inside the given path. It behaves instead as if a pattern of * had been set, rather than an empty string.
It should be noted that the emulator does not implement f_findfirst itself - instead it patches over f_opendir and f_readdir, the building blocks that f_findfirst makes use of. inside f_findfirst fatfs first sets a pat value on the dir object passed into the function to the pattern being matched for the find call. it then calls f_findnext which in turn will call f_readdir to read the first matching directory entry.
It should be noted that file pattern matching does work inside the emulator. calling f_findfirst with a pattern string that is anything besides an empty string will work as expected. (At this time I cannot see how it accomplishes that.)
A simple work-around for this limitation (discovered whilst writing this ticket 😁 ) is to set the pattern to .. ideally the emulator should use that work-around itself, as when MOS eventually exposes the use of f_findfirst to other applications they may run into this same issue
The text was updated successfully, but these errors were encountered:
When MOS makes a call to the faffs's
f_findfirst
function, passing in a pattern of""
(i.e. an empty string) and providing a path to a valid directory, the expected behaviour from fatfs is to returnFR_OK
, but leave the file info object with an empty filename, as there was not actually a file to match againstThe emulator however will return the first file it finds inside the given path. It behaves instead as if a pattern of
*
had been set, rather than an empty string.It should be noted that the emulator does not implement
f_findfirst
itself - instead it patches overf_opendir
andf_readdir
, the building blocks thatf_findfirst
makes use of. insidef_findfirst
fatfs first sets apat
value on thedir
object passed into the function to the pattern being matched for the find call. it then callsf_findnext
which in turn will callf_readdir
to read the first matching directory entry.It should be noted that file pattern matching does work inside the emulator. calling
f_findfirst
with a pattern string that is anything besides an empty string will work as expected. (At this time I cannot see how it accomplishes that.)A simple work-around for this limitation (discovered whilst writing this ticket 😁 ) is to set the pattern to
.
. ideally the emulator should use that work-around itself, as when MOS eventually exposes the use off_findfirst
to other applications they may run into this same issueThe text was updated successfully, but these errors were encountered: