Saving preference files in the application package (Mac)
On the Mac, with Max 5, can a Max application save it's preference files in the .app package, so that the user doesn't see them in the Finder?
I mean the content you see when you right-click the application: "Show Package Content"
If yes, which file path do I have to use?
To save preferences, I use a pattrstorage with its file saved into the .app's Contents/Resources folder. And no file path at all.
Something like this:
How do you save without a file path? Your patch in Max or as compiled version (.app), on close I get asked to save the preference file. I cannot save without a path.
In my application I save on demand by sending "writexml settings.xml" (without path information) to [pattrstorage]. The file gets written to the current folder. In the .app the same happens, the file does not go to the Content/Resources/ folder.
I see a file path parameter in the patcher inspector but cannot delete it to make "no path". It's a locked field.
I first save the pref in Max, to create a xml file. Then I move it into the standalone in /Resources by hand. Once the right file is in the search path, it will be replaced with writeagain.
Thanks, I think the 'writeagain' was the clue.
However, I tried about 30 times and it worked just once and never again. Even my Max got crazy. It started to write .json files with the 'writexml' message, it put my file to the Max folder, always I got write errors in the .app – but it worked once, so I know it can work. Somehow, some time, hopefully, again ;-)
Got it, finally.
Could not manage 'writeagain' but found the way to use absolute paths. If someone is interested, below is a patch that reports the current path, be it a Max patch (saved as file) or an application. Works in Max 5 and 6.
Description:
If the message "; max getruntime ..." sends 0, you send "path" to [thispatcher]. If the message sends 1, you are in runtime mode and execute "; max sendapppath ..." to get the current path. Quite simple.