NoSenseEtAl
NoSenseEtAl

Reputation: 30118

Replacement for deprecated boost filesystem initial_path

Like the title says I'm in a search for a way to do to do the initial_path(). As you can see here there is no replacement: http://www.boost.org/doc/libs/1_46_0/libs/filesystem/v3/doc/deprecated.html

Upvotes: 0

Views: 2290

Answers (2)

O.C.
O.C.

Reputation: 6829

Are you looking for a way to get full path to your executable ?

Read this SO question

I think the answer is as below (thanks to Mike)

Here's code to get the full path to the executing app:

Windows:

int bytes = GetModuleFileName(NULL, pBuf, len);
if(bytes == 0)
        return -1;
else
        return bytes;

Linux:

char szTmp[32];
sprintf(szTmp, "/proc/%d/exe", getpid());
int bytes = MIN(readlink(szTmp, pBuf, len), len - 1);
if(bytes >= 0)
        pBuf[bytes] = '\0';
return bytes;

Upvotes: 1

Assaf Lavie
Assaf Lavie

Reputation: 76093

Why not just remember it yourself with some variable? Why do you need boost to take care of this? As they say in the docs, this is trivially taken care of by the user.

Upvotes: 1

Related Questions