News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

acquire the current projects directory ?

Started by metalfan, February 03, 2011, 06:47:24 PM

Previous topic - Next topic

metalfan

Is it possible to acquire the current project's directory (via the plugin) ?
I need it to pass it via the commandline on to a another programm...

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

dushara


metalfan

I think the thing dushara posted is what i were looking 4, but it doesn't work (it says it isn't defined...)...
This variable_expansion is just a list of predefines, but i need the directory of the currently loaded project when invoking the plugin...

dushara

This works for me...


void my_plugin::OnProjectOpen( CodeBlocksEvent& event )
{
    cbProject* prj = event.GetProject();

    if(!prj)
    {
        return;
    }

    const wxString& prj_file = prj->GetFilename();

    ...
}


Don't forget to register the event handler...


void my_plugin::OnAttach()
{
    Manager::Get()->RegisterEventSink(cbEVT_PROJECT_OPEN, new cbEventFunctor<my_plugin, CodeBlocksEvent>(this, &my_plugin::OnProjectOpen));
}