News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Get current project path name

Started by bear24rw, October 21, 2007, 10:27:58 PM

Previous topic - Next topic

bear24rw

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

bear24rw

#1
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

thomas

QuoteIf 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).

QuotewxString 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."