problem with working directory [solved]
problem with working directory [solved]
Hi all,
i want to load a scene from directory, but cannot, in the console written like this :
could not load mesh, because file could cot be opened: meshes/tipe21/house21.irr
could not open file of texture: material/wood.bmp
...
etc
i think my problem on the working directory, like in the irredit, that the working directory can be setting,
than how to change my working directory on my code?
plz anybody help me, sorry for my bad english.
thanks
i want to load a scene from directory, but cannot, in the console written like this :
could not load mesh, because file could cot be opened: meshes/tipe21/house21.irr
could not open file of texture: material/wood.bmp
...
etc
i think my problem on the working directory, like in the irredit, that the working directory can be setting,
than how to change my working directory on my code?
plz anybody help me, sorry for my bad english.
thanks
Last edited by wiznoe on Mon Aug 18, 2008 4:52 am, edited 2 times in total.
Hi JP & Pera,
sorry, maybe i'm stupid, but i can't change the working directory in my irrlicht app.
This is my code :
this code is path of IEventReceiver, that the file of scene is open from FileOpenDialog. I confused that where the code of changeWorkingDirectory have placed.
Please help me, maybe all of u have a sample code like my mean..
Sorry for my english, i wish u know.
sorry, maybe i'm stupid, but i can't change the working directory in my irrlicht app.
This is my code :
Code: Select all
case EGET_FILE_SELECTED:
{
IFileSystem * m_FS = device->getFileSystem();
printf("\n#dir1:: %s",stringc(m_FS->getWorkingDirectory()).c_str());
IGUIFileOpenDialog* dialog =
(IGUIFileOpenDialog*)event.GUIEvent.Caller;
smgr->clear();
loadRumah(smgr,stringc(dialog->getFileName()).c_str());
stringc m_WorkingDirectory = "C:\SPPK Rumah V1.4\sppk\sppk.";
m_FS->changeWorkingDirectoryTo(m_WorkingDirectory.c_str());
printf("\ndir now in= %s",stringc(m_FS->getWorkingDirectory()).c_str());
}
Please help me, maybe all of u have a sample code like my mean..
Sorry for my english, i wish u know.
you should post what is the problem - is there compiler error, what dir have you end up in?
I see two potential problems,
1 problem is in line
stringc m_WorkingDirectory = "C:\SPPK Rumah V1.4\sppk\sppk.";
cause escape character \ can act weird in that string. Change it to \\ or /
second, EGET_FILE_SELECTED is event called after you pick your scene! so you are already in the wrong dir (not the root one)
go to the code where you call the FileOpenDialog to appear, there, before calling dialog, store your working dir:
stringc m_WorkingDirectory = m_FS->getWorkingDirectory();
then in eget file selected event write
m_FS->changeWorkingDirectoryTo(m_WorkingDirectory.c_str());
BEFORE loading your scene
I had probles with that too
I see two potential problems,
1 problem is in line
stringc m_WorkingDirectory = "C:\SPPK Rumah V1.4\sppk\sppk.";
cause escape character \ can act weird in that string. Change it to \\ or /
second, EGET_FILE_SELECTED is event called after you pick your scene! so you are already in the wrong dir (not the root one)
go to the code where you call the FileOpenDialog to appear, there, before calling dialog, store your working dir:
stringc m_WorkingDirectory = m_FS->getWorkingDirectory();
then in eget file selected event write
m_FS->changeWorkingDirectoryTo(m_WorkingDirectory.c_str());
BEFORE loading your scene
I had probles with that too
Plus you shouldn't ever set a path like C:/blah/blah because that relies on a specific driver and directory structure which you will not have control over on a user's PC if you decide to release your app so you should only do this if you're using the app only your PC for its entire life, and even then it's bad practice.