When trying to open a file using fopen, in the current working directory from the console, it can't find the file unless the fopen happens before the Irrlicht 'createDevice' call. (Irrlicht 1.5.1)
Is this change in current working directory intended?
Thanks,
Erwin
Irrlicht 'createDevice' changes current working directory?
-
- Posts: 46
- Joined: Tue Oct 02, 2007 6:46 am
- Contact:
I haven't tested this, but it would be nice if you had a testcase to verify this. The following should work on most systems.
Of course it would be better if you just pointed out where the working directory was being changed. That way bitplane doesn't have to go hunting for it.
Travis
Code: Select all
#include <irrlicht.h>
#include <string.h> // for strcmp()
#include <assert.h> // for assert()
#if defined (_IRR_WINDOWS_API_)
# include <direct.h> // for _getcwd()
# define getcwd(x,y) _getcwd(x,y)
#else
# include <unistd.h> // for getcwd()
#endif
using namespace irr;
int main ()
{
char buf1 [PATH_MAX + 1];
getcwd (buf1, sizeof buf1);
IrrlichtDevice* device = createDevice (video::EDT_NULL);
char buf2 [PATH_MAX + 1];
getcwd (buf2, sizeof buf2);
device->drop();
assert (!strcmp (buf1, buf2));
return 0;
}
Travis
-
- Posts: 46
- Joined: Tue Oct 02, 2007 6:46 am
- Contact:
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
So this does not happen with the null driver? That's an interesting point, at least a hint where it might happen. Can you debug into the createDevice call and check if it happens in createWindow or createDriver?
Edit: Seems to happen with every driver:
Edit: Seems to happen with every driver:
Code: Select all
path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
chdir([path fileSystemRepresentation]);