I’ve been having problems with the ofToDataPath() solution. I’m trying to access files embedded into the Mac application’s .app “contents” package, and despite claims to the contrary (http://www.openframeworks.cc/setup/xcode#notes-structure), the ofToDataPath() function ends up throwing me outside of the contents of the package.
So I came up with this hack for when I want to access the internal .app folder, instead of the data/ folder, but it’s an ugly hack even if it doesn’t do any damage. Basically, I just preceed my filename with ./ and it ignores the whole …/…/…/ prefix.
I’ll let theo jump in, but just to note that the setup instructions out of date on that point – the ofDataPath() was added later and in order to normalize all platforms so that it’s much easier to share code – each exe comes with a nearby data folder that has external files. This improves greatly the process of posting and sharing example code.
I like your solution. Another option is something like,
which would allow you to bypass that internal call as you please (and write mac specific code, etc). what do you think?
anyway, I’m wondering if there is a reason for wanting to put files in the package ?
which would allow you to bypass that internal call as you please (and write mac specific code, etc). what do you think?[/quote]
Yeah, that’s a good idea. Less of a hack than my solution. We should have that.
Because I wanted a simple distribution, i.e. one single file/icon to move around when I’m on a Mac. It’s a lot cleaner like that. I don’t know how you’re supposed to do it officially on Windows, but I really like the package system on the Mac.
For the current project, these are tiny .PNG and .AIF, and are just interface ingredients. Their logical place is in the package itself.
I am trying to get something to run on windows and I am having problems with ofToDataPath(). I was not able to load any fonts unless I set the ofSetDataPathRoot(“bin/data/”). When I start the exe from explorer it’s fine though.
Seems to me that VS2008 runs the exe from the path were the project file is and not where the exe is. I notices that the fontExample runs fine. Is there a project file setting I am missing … so frustrating!
@stefan, be careful how you duplicate the files and check the readme.txt about this. it’s just that you are likely not copying or using the general .user which which should have a “run the app from bin” type command (the directory to run from is not in the .vcproj or .sln file). the general .user file gets turned into a more specific user file once you launch the .vcproj for the first time (ie, blah.user.stefanix or something like that) and it should contain the right info.
Thank you guys, I was about to lose it. I must have spent 2h just searching for a settings option in the UI. Somehow I was under the assumption the user file was only for storing less important things.