Is it save to use getWritablePath()?

Hello!

I want to save some game data and found this http://www.cocos2d-x.org/wiki/How_to_read_and_write_file_on_different_platforms

I also found out that this may be problematic because of this Please help cocos2d-x to determine what's the correct path to save a file on iOS and Android

Okay… And now? The “please help cocos2d-x to determine correct path” only ends without something like “okay, i will fix that”. The wikipage is too old (the page is from 2011, the thread from 2013), so it’s not updated. I am unsure if this works.

Is it save to use

auto path = FileUtils::getInstance()->getWritablePath(); 

and create files? Thanks!

Can anyone give advice?

it’s a good question that’s why i am replying back even if it is asked a long time ago!
i invite you to look at these facts and answer the question your self!

we will look at where the path is located in each device and look at how secure these paths are.

in general the path returned by getWritablePath() represents apps internal storage which gets removed when the app is uninstalled.

so in order to know whether it’s safe or not we have to look at the folder path returned by getWritablePath() accessibility therefore we have see the return value in each device which is:

in android the returned path is for a folder called files which is according to developer.android.com is a private storage accessible only to the app which means its safe and here is the picture of how a android cocos2d-x app internal storage look like:

and here is the article that confirms the path safety on android:
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

in ios am not sure but by examining the code for getWritablePath() on ios i think the path is for a folder called Documents which according to apple should be used for data that you want to expose so it shouldn’t be used for sensitive data any other data is fine.
so here is the article that confirms the path unsafety on ios:

https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW28

and here is the picture of how an ios app internal storage look like:

in wp8.1 the path is for a folder called Local which is acording to the article below is not safe for sensetive data any other data is fine
so here is the article that confirms the path unsafety on wp8.1 look at this question “Q. Is local or roaming app data secured in any way?”
https://blogs.windows.com/buildingapps/2014/06/19/common-questions-and-answers-about-files-and-app-data-part-1-app-data/

and here is the picture of how a wp8.1 app internal storage look like:

at last i hope now you’re able to answer your question!