std::experimental::filesystem::hard_link_count
Min standard notice:
Header: <experimental/filesystem>
Returns the number of hard links for the filesystem object identified by path p.
# Declarations
std::uintmax_t hard_link_count( const path& p );
std::uintmax_t hard_link_count( const path& p, error_code& ec );
(filesystem TS)
# Parameters
p: path to examineec: out-parameter for error reporting in the non-throwing overload
# Return value
The number of hard links for p.
# Example
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
// On a POSIX-style filesystem, each directory has at least 2 hard links:
// itself and the special member pathname "."
fs::path p = fs::current_path();
std::cout << "Number of hard links for current path is "
<< fs::hard_link_count(p) << '\n';
// each ".." is a hard link to the parent directory, so the total number
// of hard links for any directory is 2 plus number of direct subdirectories
p = fs::current_path() / ".."; // each dot-dot is a hard link to parent
std::cout << "Number of hard links for .. is "
<< fs::hard_link_count(p) << '\n';
}