std::experimental::filesystem:: space
|
Definiert im Header
<experimental/filesystem>
|
||
|
space_info space
(
const
path
&
p
)
;
space_info space ( const path & p, error_code & ec ) noexcept ; |
(Filesystem TS) | |
Bestimmt die Informationen über das Dateisystem, auf dem der Pfadname
p
sich befindet, wie durch POSIX
statvfs
.
Füllt ein Objekt vom Typ
space_info
und gibt es zurück, gesetzt aus den Mitgliedern der POSIX
struct statvfs
wie folgt:
- space_info. capacity wird gesetzt als ob durch f_blocks * f_frsize .
- space_info. free wird gesetzt auf f_bfree * f_frsize .
- space_info. available wird gesetzt auf f_bavail * f_frsize .
- Jedes Mitglied, das nicht bestimmt werden konnte, wird gesetzt auf static_cast < std:: uintmax_t > ( - 1 ) .
Die nicht-werfende Überladung setzt alle Member auf static_cast < std:: uintmax_t > ( - 1 ) bei einem Fehler.
Inhaltsverzeichnis |
Parameter
| p | - | zu untersuchender Pfad |
| ec | - | Out-Parameter für Fehlerberichterstattung in der nicht-werfenden Überladung |
Rückgabewert
Die Dateisysteminformationen (ein
space_info
Objekt).
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 hasHinweise
space_info. available kann kleiner sein als space_info. free .
Beispiel
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { fs::space_info devi = fs::space("/dev/null"); fs::space_info tmpi = fs::space("/tmp"); std::cout << " Capacity Free Available\n" << "/dev: " << devi.capacity << " " << devi.free << " " << devi.available << '\n' << "/tmp: " << tmpi.capacity << ' ' << tmpi.free << ' ' << tmpi.available << '\n'; }
Mögliche Ausgabe:
Capacity Free Available
/dev: 4175114240 4175110144 4175110144
/tmp: 420651237376 411962273792 390570749952
Siehe auch
|
Informationen über freien und verfügbaren Speicherplatz im Dateisystem
(Klasse) |