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

[rcore] fix: ScanDirectoryFiles() and ScanDirectoryFilesEx() creates dependency on module rtext #4758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mannikim
Copy link

the functions ScanDirectoryFiles() and ScanDirectoryFilesEx() both use the function TextFindIndex() which is defined in rtext.c, and requires the flags SUPPORT_MODULE_RTEXT and SUPPORT_TEXT_MANIPULATION to be defined

this pull request introduces #if directives to prevent the use of TextFindIndex by disabling filtering directories in these functions

@sleeptightAnsiC
Copy link
Contributor

sleeptightAnsiC commented Feb 10, 2025

Shouldn't this just use a LibC equivalent of TextFindIndex() which would be slightly modified strstr() ?

The rest of ScanDirectoryFiles/Recursively() already uses LibC calls from <string.h> so someone made sure to decouple it from rtext and probably forgot about this one single function.

Adding #if around single branch would only silently break those as files->count will not be properly incremented.

@mannikim
Copy link
Author

Shouldn't this just use a LibC equivalent of TextFindIndex() which would be slightly modified strstr() ?

that would be a good alternative, since it would retain the directory filtering feature. i was afraid of changing the code too much

Adding #if around single branch would only silently break those as files->count will not be properly incremented.

the pointer only increments if the filter string contains DIR. since the idea was to deactivate this feature if SUPPORT_TEXT_MANIPULATION is off, it is working as intended, as you wouldn't be able to compile without it anyways
also, i couldn't find any use of this feature through the rest of the library, so there is nothing breaking internally

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

Successfully merging this pull request may close these issues.

2 participants