Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ofSetDataPathRoot doing what it shouldn't #1522

Closed
elliotwoods opened this Issue Aug 30, 2012 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

elliotwoods commented Aug 30, 2012

Currently ofSetDataPathRoot reads as:

//--------------------------------------------------
void ofSetDataPathRoot(string newRoot){
    string newPath = "";

    #ifdef TARGET_OSX
        #ifndef TARGET_OF_IPHONE
            char path[MAXPATHLEN];
            uint32_t size = sizeof(path);

            if (_NSGetExecutablePath(path, &size) == 0){
                //printf("executable path is %s\n", path);
                string pathStr = string(path);

                //theo: check this with having '/' as a character in a folder name - OSX treats the '/' as a ':'
                //checked with spaces too!

                vector < string> pathBrokenUp = ofSplitString( pathStr, "/");

                newPath = "";

                for(int i = 0; i < pathBrokenUp.size()-1; i++){
                    newPath += pathBrokenUp[i];
                    newPath += "/";
                }

                //cout << newPath << endl;   // some sanity checks here
                //system( "pwd" );

                chdir ( newPath.c_str() );
                //system("pwd");
            }else{
                ofLog(OF_LOG_FATAL_ERROR, "buffer too small; need size %u\n", size);
            }
        #endif
    #endif

    dataPathRoot() = newRoot;
    isDataPathSet() = true;
}

After talking to @ofTheo , it's important to make sure that our working directory is set to our .app enclosing folder so our data folder keeps the same relative location.

This function is generally first made at the first call of ofToDataPath, meaning that ofToDataPath can change your working directory. Therefore I suggest we:

  1. Move this to ofRunApp
  2. Rewrite this using Poco::Path
  3. Implement this for Windows/VS also (to avoid $(TargetDir) issues)
Contributor

ofTheo commented Aug 30, 2012

Great - would be great to have this on a branch so we can test it heavily!

Owner

bilderbuchi commented Jul 17, 2013

Closed by #1523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment