openframeworks / openframeworks/openFrameworks
can't access Resources/ inside main()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
I have an app that needs to do some things (like decide whether to decorate the window) before the app is run. This needs to be configured by a file inside the Resources/ folder. Usually the solution is to add ofSetDataPathRoot("../Resources"); but that doesn't work inside main():
#include "ofMain.h"
int main() {
ofSetDataPathRoot("../Resources");
ofLog() << ofToDataPath(".", true);
}
[notice ] /Users/kyle/Documents/openFrameworks/apps/Project/App/bin/../Resources/.
I also tried adding ofRestoreWorkingDirectoryToDefault(), ofSetDataPathRoot(".") and ofToDataPath(".") before ofSetDataPathRoot().
The only solution I found is to imitate the code inside defaultDataPath():
ofSetDataPathRoot(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../Resources"));
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing ofSetDataPathRoot(), ofToDataPath(), and defaultDataPath(), then compare their behavior when called from main(). Inspect the existing ofFilePath::getCurrentExeDir() workaround and verify the expected Resources/ path on macOS; done means the documented call works inside main() without manually reproducing defaultDataPath().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100