Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: metalfan on February 03, 2011, 06:47:24 pm

Title: acquire the current projects directory ?
Post by: metalfan on February 03, 2011, 06:47:24 pm
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...
Title: Re: acquire the current projects directory ?
Post by: stahta01 on February 03, 2011, 07:25:47 pm
http://wiki.codeblocks.org/index.php?title=Variable_expansion
Title: Re: acquire the current projects directory ?
Post by: dushara on February 04, 2011, 06:28:58 am
See the first 2 messages in this thread: http://forums.codeblocks.org/index.php/topic,13723.msg92491.html#msg92491

I think that's what you want.
Title: Re: acquire the current projects directory ?
Post by: metalfan on February 04, 2011, 09:31:35 pm
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...
Title: Re: acquire the current projects directory ?
Post by: dushara on February 06, 2011, 12:00:00 am
This works for me...

Code
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...

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