Author Topic: Get current project path name  (Read 6565 times)

Offline bear24rw

  • Multiple posting newcomer
  • *
  • Posts: 15
Get current project path name
« on: October 21, 2007, 10:27:58 pm »
Hi, how do i find the current projects complete directory location...

I thought it might be something like this..

    wxString exeFileName = _("${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_FILE}");
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars (exeFileName);

But I don't know what the variable name would be..

Any help would be appreciated

Offline bear24rw

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Get current project path name
« Reply #1 on: October 21, 2007, 10:30:48 pm »
Answered my own question
I found a list of variables in macrosmanager.cpp

I am now using

    wxString proj_direc= _("${PROJECT_DIRECTORY}");
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars (proj_direc);

And it works, but...

If i open a project, it gives me the right path.. if i close the project and immediately open another one.. it still gives me the path of the old project.. but if i close the project.. try to get the path its blank (like it should be) and then open a project it gives me the right path of the new project

Is there any way of like making sure the variables are 'refreshed'?


//// EDIT

So I just traced back the functions to figure out what they were doing and ending up with...

wxString exeFileName = UnixFilename(Manager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath());

Which solves the problem i was having before, so im good now
« Last Edit: October 21, 2007, 11:02:55 pm by bear24rw »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Get current project path name
« Reply #2 on: October 22, 2007, 10:10:25 am »
Quote
If i open a project, it gives me the right path.. if i close the project and immediately open another one.. it still gives me the path of the old project.. but if i close the project.. try to get the path its blank (like it should be) and then open a project it gives me the right path of the new project
This is a "normal" behaviour from MacrosManager's point of view. And although it is obviously wrong, there is little one can do about it right now.
The problem lies in a deficiency of ProjectManager paired with a bad use of build targets (which, unluckily, Code::Blocks encourages you to do, too).

Quote
wxString exeFileName = UnixFilename(Manager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath());
That's the correct way to do what you wanted.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."