Working Directory on OSX

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dbacchet
Posts: 1
Joined: Sat Apr 11, 2009 8:41 am

Working Directory on OSX

Post 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
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Post 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
Post Reply