Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Get current project path name

(1/1)

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:
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:

--- 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
--- End quote ---
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());
--- End quote ---
That's the correct way to do what you wanted.

Navigation

[0] Message Index

Go to full version