std::experimental::filesystem:: hard_link_count
From cppreference.net
<
cpp
|
experimental
|
fs
|
Definiert im Header
<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) |
Gibt die Anzahl der festen Verknüpfungen für das Dateisystemobjekt zurück, das durch den Pfad p identifiziert wird.
Die nicht-werfende Überladung gibt bei Fehlern static_cast < uintmax_t > ( - 1 ) zurück.
Inhaltsverzeichnis |
Parameter
| p | - | zu untersuchender Pfad |
| ec | - | Out-Parameter für Fehlerberichterstattung in der nicht-werfenden Überladung |
Rückgabewert
Die Anzahl der Hardlinks für p .
Ausnahmen
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
Spezifikation:
noexcept
Beispiel
Diesen Code ausführen
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { // Auf einem POSIX-artigen Dateisystem hat jedes Verzeichnis mindestens 2 Hardlinks: // sich selbst und den speziellen Pfadnamen "." fs::path p = fs::current_path(); std::cout << "Number of hard links for current path is " << fs::hard_link_count(p) << '\n'; // jeder ".."-Eintrag ist ein Hardlink zum Elternverzeichnis, daher ist die Gesamtzahl // der Hardlinks für jedes Verzeichnis 2 plus die Anzahl der direkten Unterverzeichnisse p = fs::current_path() / ".."; // jeder Punkt-Punkt-Eintrag ist ein Hardlink zum Elternverzeichnis std::cout << "Number of hard links for .. is " << fs::hard_link_count(p) << '\n'; }
Ausgabe:
Number of hard links for current path is 2 Number of hard links for .. is 3
Siehe auch
|
erstellt einen Hardlink
(Funktion) |