Author Topic: acquire the current projects directory ?  (Read 6270 times)

Offline metalfan

  • Single posting newcomer
  • *
  • Posts: 3
acquire the current projects directory ?
« 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...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline dushara

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: acquire the current projects directory ?
« Reply #2 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.

Offline metalfan

  • Single posting newcomer
  • *
  • Posts: 3
Re: acquire the current projects directory ?
« Reply #3 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...

Offline dushara

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: acquire the current projects directory ?
« Reply #4 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));
}