Unfortunately, several applications I’ve worked on have been knocked back because of the issue of using certain locations on the device to save content that those locations are not suitable for, so the locations had to be changed before the apps were approved. This isn’t a Cocos2d-x specific issue either, but given that there is only one method, which is
getWritablePath(), there is only one path returned.
On iOS, that path is
Documents/, which is a folder that is backed up to the Apple cloud service. The bigger the content, the longer it takes for user data to be backed up, so Apple placed restrictions on what content should be placed in that path.
For instance, this is an excerpt from the Apple docs:
Put user data in
Documents/ . User data generally includes any files you might want to expose to the user—anything you might want the user to create, import, delete or edit. For a drawing app, user data includes any graphic files the user might create. For a text editor, it includes the text files. Video and audio apps may even include files that the user has downloaded to watch or listen to later.
Now, say your app requires downloadable content, something that can be hundreds of megabytes of data. That data cannot be placed in
Documents/ on iOS, and instead needs to be placed in either
Library/Application support/ or
Library/Cache, depending on specific use cases.
Perhaps for the majority of apps made with Cocos2d-x, where there is only a need to save small files, then
Documents/ is fine, as long as that data should be accessible to the user (the user can browse that location), and that the data needs to be backed up. If that data is large (even a few MB), and can be recreated any time, then it shouldn’t go in that path, because it’s just taking up bandwidth and storage space in the user cloud storage (which has limits).
It’s trivial to implement code once that can be re-used in applications to return more appropriate paths depending on the type of data that will be written. For example:
Each one has a very specific purpose, and on some platforms (like Windows), the paths returned by all may be exactly the same; it really depends on the requirements set out by that platform.