path::has_parent_path Method

Specifies whether the stored file name contains a parent path.

bool has_parent_path() const;

Return Value

true if the parent path is not empty; otherwise, false.

    path p(L"C:\\MyDir");
    path p2(L"\\SomeRandomDir");
    path p3(L"PathWithoutSeparator");
    wcout << boolalpha << L"C:\\MyDir " << "has parent = " 
        << p.has_parent_path() << endl;
    wcout << boolalpha << L"\\SomeRandomDir " << "has parent = " 
        << p2.has_parent_path() << endl;
    wcout << boolalpha << L"PathWithoutSeparator " << "has parent = " 
        << p3.has_parent_path() << endl;

      // Output:
     // C:\MyDir has parent = true
     //  \SomeRandomDir has parent = true
     //  PathWithoutSeparator has parent = false

Requirements

Header: filesystem

Namespace: std::tr2::sys

See Also

Reference

path Class (C++ Standard Template Library)

path::parent_path Method

<filesystem>