Zain Rizvi
Zain Rizvi

Reputation: 24636

How to get the fully qualified path name in C++

Is there a function that returns the fully qualified path name for any inputted file?

I'm thinking of something like:

LPCSTR path = "foo.bar"
LPCSTR fullPath = FullyQualifiedPath(path);
//fullPath now equals C:\path\to\foo.bar

Thanks

Upvotes: 3

Views: 2848

Answers (2)

Benjamin Lindley
Benjamin Lindley

Reputation: 103693

Use boost::filesystem http://www.boost.org/doc/libs/1_44_0/libs/filesystem/v2/doc/index.htm

#include <iostream>
#include <boost/filesystem.hpp>

int main()
{
    boost::filesystem::path p = boost::filesystem::complete("foo.bar");
    std::cout << p;
}

Upvotes: 3

Greg Hewgill
Greg Hewgill

Reputation: 992807

In Win32, call the GetFullPathName function.

Upvotes: 4

Related Questions