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

open file i GetCacheDir bad fopen mode "rt" #18

Closed
GreenSnakeLinux opened this issue Sep 13, 2024 · 4 comments
Closed

open file i GetCacheDir bad fopen mode "rt" #18

GreenSnakeLinux opened this issue Sep 13, 2024 · 4 comments

Comments

@GreenSnakeLinux
Copy link
Contributor

Hello,

When I want to read a file in cache folder using GetCacheDir()
I need to use: fopen(fileName, "r");
because LoadFileText(fileName) use mode "rt" and return "Failed to open text file"
Why use "rt" ? Strangely, files open in asset folder is working with LoadFileText and mode "rt" but not with "r"

@Bigfoot71
Copy link
Owner

Bigfoot71 commented Sep 13, 2024

Hi, my memory isn't very fresh on all this, but I know that raylib internally uses its "own version" of fopen (see utils.c) for Android.

This might be the reason why LoadFileText is unable to read from the directory provided by GetCacheDir. To be verified...

Edit: But it’s normal to use "rt" to open a text file, "rt" opens a file for reading in text mode and handles newline translations, for example. Try LoadFileData if it is not a text file otherwise.

@GreenSnakeLinux
Copy link
Contributor Author

you're right it is not related to "rt" mode but with:
#define fopen(name, mode) android_fopen(name, mode)
I have created a pull request, to have a new read function, that does not read in Assets folder but everywhere including cache directory.

@Bigfoot71
Copy link
Owner

@GreenSnakeLinux I just reviewed your contribution, and aside from a few minor things to address, it looks great! Thank you again!

@Bigfoot71
Copy link
Owner

Completed with: #19 and 9ea2fe1

Thanks again @GreenSnakeLinux ! :)

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

2 participants