Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
async_statfs

Asynchronous volume enumeration after a preceding operation.

Description

Related types: statfs_t

Synopsis
future<statfs_t> async_statfs(future<> _precondition, fs_metadata_flags req)
Parameters

Type

Concept

Name

Description

future<>

_precondition

The precondition to use.

fs_metadata_flags

req

A metadata request.

Returns

A future<statfs_t>

Header

#include <boost/afio/v2/afio.hpp>

Race Guarantees

Operating system Race guarantees under a changing file system
FreeBSD, OS X Race free.
Linux The following items are fetched in a single snapshot: bsize, iosize, blocks, bfree, bavail, files, ffree, namemax, fsid, flags.rdonly, flags.noexec, flags.nosuid.
Windows The following snapshot categories apply: (i) flags, namemax, fstypename (ii) bsize, blocks, bfree, bavail. Everything else is fetched separately.

Complexity

Amortised O(1) to dispatch. Amortised O(1) to complete.

Exception Model

Propagates the exception of any input precondition with an errored state at the point of dispatch, and throws a std::invalid_argument if any inputs have values which could not possibly be correct. Note that error code returning functions may still throw exceptions e.g. failure to allocate memory.

Example
boost::afio::current_dispatcher_guard h(boost::afio::make_dispatcher().get());

// Open the root directory
boost::afio::handle_ptr rootdir(boost::afio::dir("/"));

// Ask the filing system of the root directory how much free space there is
boost::afio::statfs_t statfs(
boost::afio::statfs(rootdir, boost::afio::fs_metadata_flags::bsize |
                             boost::afio::fs_metadata_flags::bfree));

std::cout << "Your root filing system has "
          << (statfs.f_bfree * statfs.f_bsize / 1024.0 / 1024.0 / 1024.0)
          << " Gb free." << std::endl;


PrevUpHomeNext