Page 1 of 1

Working Directory on OSX

Posted: Sat Apr 11, 2009 8:53 am
by dbacchet
Hello Everybody,

I'm wondering on how the current working directory is calculated in OSX.

My executable (a plain unix executable file, not an apple bundle) is placed in the folder:
/Users/dbs/dev/learn/irrlicht/learn1/build/learn1/Debug/

I wrote a simple test case:

Code: Select all

    IFileSystem*     fs     = device->getFileSystem();
    std::cout << "workingdir:" << fs->getWorkingDirectory() << std::endl;
    std::cout << "file:      " << argv[0] << std::endl;
    std::cout << "filedir:   " << fs->getFileDir(argv[0]).c_str() << std::endl;
    std::cout << "absfiledir:" << fs->getAbsolutePath(argv[0]).c_str() << std::endl;
    std::cout << "absfiledir:" << fs->getAbsolutePath(fs->getFileDir(argv[0])).c_str() << std::endl;
and I get the following output:

Code: Select all

workingdir:/Users/dbs/dev/learn/irrlicht/learn1/build
file:      ./learn1
filedir:   .
absfiledir:/Users/dbs/dev/learn/irrlicht/learn1/build/learn1
absfiledir:/Users/dbs/dev/learn/irrlicht/learn1/build
The *really* strange behavior is that the "Debug" folder is always omitted using the standard IFilesystem calls. Is this something wanted?
I tried with several different dir structures (maybe the dir "Debug" was a special name...) but nothing changed.

Any idea on how to set the current working dir to the exact path where the executable is placed?

thanks!! and sorry if I asked a stupid question...
Davide

Posted: Wed Sep 22, 2010 6:34 pm
by drewbacca
I am having the same problem. I don't do much with osx, but I had someone compile code for a project using osx. The osx built version omits the final directory when calling getWorkingDirectory().

I don't have a lot of details, just that it was built with gcc on osx.

Also, this is with the 1.7 branch of svn