Working directory changed - mac os x

nobody wrote on Wednesday, May 07, 2008:


I have a simple application written with glfw and am experiencing problems with current working directory.

I read in files with fopen once the program starts. I can successfully read in a file with FILE* fp = fopen("level1.txt", "r") in a constructor of an object that is global.

But when I try to read in the same file with same code later in the code, it fails with errno == 2 (no such file or directory).

It appears that someone has changed the current working directory somewhere in the middle. Does glfw do something like this? Has someone experienced same problem on a mac?

btw, I absolutely love glfw for it’s clear and simple interface and to-the-point feature list.


elmindreda wrote on Wednesday, May 07, 2008:

GLFW on Mac OS X sets the cwd to the resource directory of your application bundle. This is intentional and by design.

nobody wrote on Thursday, May 08, 2008:

Thanks for the info. I’ll move my stuff there then. And again thanks a million for the best opengl-framework ever!

Mikko "mayoneez" Oksalahti