Bigfoot71 / raymob

Simple raylib implementation for Android
Other
77 stars 16 forks source link

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

Closed GreenSnakeLinux closed 2 weeks ago

GreenSnakeLinux commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

Bigfoot71 commented 2 weeks ago

Completed with: https://github.com/Bigfoot71/raymob/pull/19 and https://github.com/Bigfoot71/raymob/commit/9ea2fe1f962d885839ad9c585d114c2d63d5bd7d

Thanks again @GreenSnakeLinux ! :)