We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I've made a small library to export video. The library asks you to indicate where ffmpeg is found. It would be great if it could save that info so it does not ask you for each new sketch. Currently it saves a text file for each sketch.
I've seen libraries can have a data folder, and can read from it. Can you also write to it?
Comments
Sure. What happened when you tried?
How do you locate the libraries' data folder from the libraries code? sketchPath() gives you the sketch path. Is there a libraryPath()?
Wouldn't it just be sketchPath("data")? More discussion here: http://forum.processing.org/one/topic/sketchpath.html
There is also the dataPath() function: https://processing.org/discourse/beta/num_1133175174.html
(I found both of those links by simply googling "Processing sketchPath")
Also, you might want to be careful with this. For example, if somebody deploys their sketch as a runnable jar, you won't be able to write to the jar.
Maybe I should rephrase my question to "Can a library save and retrieve a unique configuration file?". I'd like to avoid having one configuration file per sketch (that I'm already doing).
I could for instance save a file to the users' home folder... but I wanted to know, since you can read data from the library's data folder, if there's a way to write to it. If you do sketchPath("data") you obviously get the sketches data folder, which is not what I'm after.
It looks like a good solution is to use the Preferences API, to let Java decide where to store those settings on each OS.
http://www.vogella.com/tutorials/JavaPreferences/article.html
The thing to do is to have the library manage the loading and saving of the configuration file that way the sketch does not need to know where the library data folder is located.
Thanks, I think using the Preferences API as I mentioned above is even better, because I don't even need to know where the settings are saved. Java and the OS take care of that.