Get cache path from device with FileUtils

With FileUtils::getInstance()->getWritablePath() I get on iOS/macOS a reference to the documents folder. It there a way to get the cache folder? My stored files can be deleted anytime the system needs more space, so how can I do it?

PS: It would also be good to have a solution for all systems (macOS, Windows, Linux, iOS, Android).

so you are saying you want your files deleted if the device needs more space?

I can only speak for the Android world, because I know that good.

You can create files in e.g. /sdcard/Android/data/packageName/files or /sdcard/Android/data/packageName/cache. The good thing about the cache folder it, that Android can anytime (your app is not running) delete the content of this folder without losing important data (it’s just a cache). In the files folder are all important files you need for your app the complete lifetime.

I know the same principle is implemented in iOS, but I can’t find any cocos2d-x call to get this folder.

(On the desktop this folder can be the tmp folder or something else, because the files aren’t important)

ok, I see. I am not sure that we have this for iOS. Have you created a GitHub issue for this yet? I can ask an engineer to have a look.

1 Like

Done :wink:

Perfect, thanks.