We are about to switch to a new forum software. Until then we have removed the registration on this forum.
My sketch has a configuration file in the "data" folder. The user should be able to edit settings used by the sketch.
When exported for Windows this data folder is plainly visible and the config file is there for editing.
However, when exporting on OSX there is no visible data folder. Seems everything gets bundled into a jar.
What's the best way to set up a sketch such that is uses an editable config file, and that config file is exposed for editing when the sketch is exported on OSX? (I assume the same approach would work on Windows since Processing is not jarring all the files as it does on OSX.)
Thanks!
Answers
So far, playing around, I find this is usable:
and pass that to the code that needs to load the config file.
After exporting the sketch on OSX I can then copy "config.jsi" into the same folder that has the .app folder and it seems to work OK. __ Downside is that the config file has to be copied by hand, so the next step would be a command-line script that does the export and the copying.
in osx the files are bundled in a package. if you right click in it there is "show package contents" that will lead to your config file, i think...
forgot the picture...
Very weird. I had been looking in the app folder and never finding the data folder or the config file, but now when I try it out I find them in application.macosx\.app\Contents\Java
So it's available.
OTOH I'm happy I poked around because getting to that file is a bit awkward because of how OSX uses "magic folders" as application packaging.
So I think I will use files in the program root for easier access (while I look into making config management fit each platforms conventions).
Thanks.
I think, in a mac that would be to store your config file in some place like ~/Library/Application Support or ~/Library/Preferences. But this is not much better than the package is it?
Perhaps you can provide a UI to set those configs inside the program itself...? Then saving in a hided place would be no problem...
I'm thinking that, if I were to put any effort into this, I should have the app handle the loading and editing of the config. It's a fairly simple text file, so a dumb text "editor" shouldn't be hard to arrange, and then it can read and write from the default "data" folder. The user never needs to know the location.
Otherwise the sketch would need to know the OS, and do something different.
I like the idea of config files being in standard locations and users able to easily use whatever text editor they prefer, but the code overhead isn't worth it.
I wonder if I could instead launch a native "File|open" dialog. Then get users can use whatever text editor they like.
https://processing.org/reference/open_.html
I'll have t try this out.
That's easy :)
Even more properties...
And this is the "propertiesNames.txt" :