std::experimental::filesystem:: hard_link_count
From cppreference.net
<
cpp
|
experimental
|
fs
|
헤더 파일에 정의됨
<experimental/filesystem>
|
||
|
std::
uintmax_t
hard_link_count
(
const
path
&
p
)
;
std:: uintmax_t hard_link_count ( const path & p, error_code & ec ) ; |
(1) | (filesystem TS) |
경로 p 로 식별되는 파일시스템 객체의 하드 링크 개수를 반환합니다.
예외를 던지지 않는 오버로드는 오류 발생 시 static_cast < uintmax_t > ( - 1 ) 를 반환합니다.
목차 |
매개변수
| p | - | 검사할 경로 |
| ec | - | non-throwing 오버로드에서 오류 보고를 위한 출력 매개변수 |
반환값
p 의 하드 링크 개수입니다.
예외
The overload that does not take an error_code & parameter throws filesystem_error on underlying OS API errors, constructed with p as the first argument and the OS error code as the error code argument. std:: bad_alloc may be thrown if memory allocation fails. The overload taking an error_code & parameter sets it to the OS API error code if an OS API call fails, and executes ec. clear ( ) if no errors occur. This overload has
noexcept
명세:
noexcept
예제
이 코드 실행
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { // POSIX 스타일 파일시스템에서 각 디렉토리는 최소 2개의 하드 링크를 가집니다: // 자기 자신과 특수 멤버 경로명 "." fs::path p = fs::current_path(); std::cout << "Number of hard links for current path is " << fs::hard_link_count(p) << '\n'; // 각 ".."는 부모 디렉토리에 대한 하드 링크이므로, 모든 디렉토리의 총 하드 링크 수는 // 2에 직접적인 하위 디렉토리 수를 더한 값입니다 p = fs::current_path() / ".."; // 각 dot-dot은 부모에 대한 하드 링크입니다 std::cout << "Number of hard links for .. is " << fs::hard_link_count(p) << '\n'; }
출력:
Number of hard links for current path is 2 Number of hard links for .. is 3
참고 항목
|
하드 링크를 생성합니다
(함수) |