[haiku-3rdparty-dev] Re: How to get App path?

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Mon, 16 Apr 2012 13:13:29 +0200

On 2012-04-16 at 11:04:27 [+0200], hey68 you <hey68you@xxxxxxxxx> wrote:
> What's the easiet way to get the path in which my be_app is running?

If you hadn't written "be_app", I would have assumed you mean the current 
working directory. There's a POSIX function getcwd() which provides the 
path as a string. Or you can use BPath(".").Path(). Or, if you need a 
BDirectory anyway, just initialize it to ".".

If you mean the directory the application's executable lives in, you can 
use the BApplication's GetAppInfo() which returns an app_info that contains 
an entry_ref to your application's executable. You can use whatever method 
you prefer to get the directory path part (e.g. BPath::GetParent()).

CU, Ingo

Other related posts: