-
-
Notifications
You must be signed in to change notification settings - Fork 297
Should dataPath be deprecated? #450
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
Comments
@kfrajer I agree that dataPath() is problematic on Android, although I would not remove or deprecate it in order to keep the API consistency with Java. If I'm not mistaken, the files originally in the sketch's data folder get packed as assets in the apk, so does not really make sense to get a data path to those. For files created by the running sketch, their correct path is sketchPath(), so dataPath() in that case should return the same. So maybe the following is a possible behavior for dataPath():
What do you think? |
Hi Andres, If not found in asset, then [step2] attempt sketchPath. Sounds great! Do you want me to implement this concept? Is there a name for Kf |
I did more testing today to capture file IO access here: https://discourse.processing.org/t/tracking-high-score-for-android/678 Kf |
@kfrajer I implemented the proposed changes with this commit: 896a76c Let me know if you think this solves the issue. Regarding your comments:
|
Releasing v4.0.2, which includes the fix we discussed before. So I'm closing this issue, but feel free to reopen if you think dataPath() should be handled differently. Thank you! |
Hi Andres, Kf |
The code below produces the next output:
Notice I have about 6 files in
data/images
and I am also creating about 8 images usingPImage.save();
before calling the functions above. From this I conclude:All images are saved in a folder at the level of
sketchPath()
. Hence, they can be accessed withsurface.getFileStreamPath("")
orsketchPath("")
. Files stored indata/images
can only be accessed withsurface.assets("images")
. This shows thatdataPath()
is of not use for Android mode. Am I correct? Or shoulddataPath()
somehow point to assets? My understanding from Android docs, the assets (obtained via AssetsManager) is read-only which means dataPath could point to assets only to read resources. My suggestion is to make dataPath to point to sketchPath as one can read and write there. For instance:then the next should all be equivalent:
Currently
dataPath()
is not clear of what it should be. I might be wrong and using not in the proper way. Reflecting on the behavior in Processing Java, dataPath should allow access to a content where data can be written or read, so it should not point to assets but to to the sketchFolder.Any changes made to dataPath should be re-consider to make sure it does not affect current external resources. That is, if any change of dataPath is implemented at all.
Lastly, notice that
image1.save("data/image1.png");
throws an error:Hopefully here I get to document resource management based on Processing and Android guidelines.
Kf
P.S. Not tested but there seems to be other access point:
path = this.getActivity().getFilesDir();
as shown here in this post.The text was updated successfully, but these errors were encountered: