dataPath() problem under Mac OS X

A user of my app has reported that it fails to save to dataPath(“settings.xml”) when it is still in the download folder, due to permissions. Apparently dataPath() points to an odd directory. Ideas?

  • App saves settings to dataPath(“settings.xml”). Should expand to “app path/app name/Contents/Java/data/settings.xml”
  • Settings are saved for the first time in settings() to generate the file
  • This fails with a permissions error. At that time, my app was in the download folder. I assume ~/Downloads/… (don’t know)
  • Curiously, the non-permitted path in the exception is not ~/Downloads/… but something like /private/var… (user coulnd’t remember)

I’m no Mac expert. I googled /private/var… and it seems to be a temp path for app store downloads. Which I do not use, it’s distributed as zip. Is there any way a downloaded, unzipped app could lead to dataPath() pointing to a non-writable directory under /private? Maybe antivirus software?

If you are referring to Processing’s settings() function, then you should refrain on doing this. The setting() function should be used only to set the size of the sketch but nothing else more. I would not recommend accessing dataPath() or any other PApplet function there. Either do this in setup() or draw() but the former is probably what you want.

I can only suggest to make sure the mac user is unzipping the file before attempting to run it. If he unzips the file, then he should know the location of this file and he will place it in a directory with writing permissions. I am assuming that you are distributing your source code so for the mac user to be able to run it in his mac machine. Is that right? I mean, is the mac user running your app using the Processing IDE or processing-java command?

Kf

Anything related to sketchPath is safe in settings() already. :shield:

you are distributing your source code so for the mac user to be able to run it in his mac machine. Is that right?

Nope. I zip the exported app on the Mac and distribute that. For a test, I’ve copied it to Downloads, doubleclicked to unzip and run it there. I don’t know what the user does with it. I assume that all Mac browsers put downloads into Downloads and not into a path without write permissions?

you should refrain on doing this. The setting() function should be used only to set the size of the sketch

Well, the window size has to come from a configuration file, so I have to use a lot more than size(). Except for dataPath(), those are probably all basic Java functions (file, xml). As to dataPath():

I would not recommend accessing dataPath() or any other PApplet function there. Either do this in setup() or draw() but the former is probably what you want

I think it was a mistake to use dataPath() on Macs anyway. My app wouldn’t run from write-protected places (e.g. Network). I’ll switch the configuration file to a place under ~/Library/Application Support/.

Got the exact dataPath() from the user:


So it was a Gatekeeper problem, caused by the “App Translocation” of Mac OS X, because the user ran a downloaded file from Downloads (while I put it there from the sketchbook):