Skip to content

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

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

Closed
wants to merge 1 commit into from

Conversation

mannikim
Copy link
Contributor

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
Contributor 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

@raysan5
Copy link
Owner

raysan5 commented Feb 12, 2025

@sleeptightAnsiC Considering rcore is already dependant on string.h, decoupling it from rtext would be a better addition than this PR.

@raysan5 raysan5 changed the title [rcore] fix: ScanDirectoryFiles() and ScanDirectoryFilesEx() creates dependency on module rtext [rcore] ScanDirectoryFiles() and ScanDirectoryFilesEx() creates dependency on module rtext Feb 12, 2025
@sleeptightAnsiC
Copy link
Contributor

sleeptightAnsiC commented Feb 13, 2025

@mannikim (see Ray's message) Would you like to create another PR for this? It just requires swapping TextFindIndex() with strstr() and slightly modifying those checks there. I was about to fix this myself but thought you may wanna contribute? :) Tag me in case you need some help.

@mannikim
Copy link
Contributor Author

@raysan5 i made a new pull request fixing it, see #4764

@sleeptightAnsiC thanks for the opportunity :)

closing it now

@mannikim mannikim closed this Feb 13, 2025
@mannikim mannikim deleted the fix-rcore-dependency branch March 31, 2025 11:30
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.

3 participants