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

pattern matching in hostfs doesn't match fatfs (f_findfirst bug) #67

Open
stevesims opened this issue Nov 14, 2024 · 0 comments
Open

pattern matching in hostfs doesn't match fatfs (f_findfirst bug) #67

stevesims opened this issue Nov 14, 2024 · 0 comments

Comments

@stevesims
Copy link
Contributor

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

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

1 participant