Boost.AFIO    Boost C++ Libraries
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
boost::afio::handle Class Reference

The abstract base class encapsulating a platform-specific file handle. More...

List of all members.

Classes

struct  mapped_file
 A holder of a mapped file. More...

Public Types

enum  open_states { closed, open, opendir }
 In which way this handle is opened or not. More...

Public Member Functions

dispatcherparent () const
 Returns the parent of this io handle.
handle_ptr container () const
 Returns a handle to the directory containing this handle. Only works if `file_flags::hold_parent_open` was specified when this handle was opened.
virtual open_states is_open () const =0
 Returns if this handle is opened or not.
virtual void * native_handle () const =0
 Returns the native handle of this io handle. On POSIX, you can cast this to a fd using `(int)(size_t) native_handle()`. On Windows it's a simple `(HANDLE) native_handle()`.
const
chrono::system_clock::time_point & 
opened () const
 Returns when this handle was opened.
virtual boost::afio::path path (bool refresh=false)=0
 Returns the path of this i/o handle right now if the handle is open and refresh is true, else last known good. May be null if the file has been deleted.
virtual boost::afio::path path () const =0
 Returns the last known good path of this i/o handle. May be null if the file has been deleted.
file_flags flags () const
 Returns the final flags used when this handle was opened.
bool opened_as_file () const
 True if this handle was opened as a file.
bool opened_as_dir () const
 True if this handle was opened as a directory.
bool opened_as_symlink () const
 True if this handle was opened as a symlink.
bool available_to_directory_cache () const
 True if this handle is used by the directory handle cache (not UniqueDirectoryHandle and is open for write and not open for write)
off_t read_count () const
 Returns how many bytes have been read since this handle was opened.
off_t write_count () const
 Returns how many bytes have been written since this handle was opened.
off_t write_count_since_fsync () const
 Returns how many bytes have been written since this handle was last fsynced.
virtual directory_entry direntry (metadata_flags wanted=directory_entry::metadata_fastpath())=0
 Returns a mostly filled directory_entry for the file or directory referenced by this handle. Use `metadata_flags::All` if you want it as complete as your platform allows, even at the cost of severe performance loss.
stat_t lstat (metadata_flags wanted=directory_entry::metadata_fastpath())
 Returns a mostly filled stat_t structure for the file or directory referenced by this handle. Use `metadata_flags::All` if you want it as complete as your platform allows, even at the cost of severe performance loss. Calls direntry(), so same race guarantees as that call.
virtual boost::afio::path target ()=0
 Returns the target path of this handle if it is a symbolic link.
virtual mapped_file_ptr map_file (size_t length=(size_t)-1, off_t offset=0, bool read_only=false)
 Maps the file into memory, returning a null pointer if couldn't map (e.g. address space exhaustion). Do NOT mix this with `file_flags::os_direct`!
virtual void link (const path_req &req)=0
 Hard links the file to a new location on the same volume.
virtual void unlink ()=0
 Unlinks the file from its present location as determined by path(true), which could be any hard link on those operating systems with an unstable path(true). Other links may remain to the same file.
virtual void atomic_relink (const path_req &req)=0
 Links the file to a new location and unlinks the file from its present location as determined by path(true), atomically overwriting any file entry at the new location. Very useful for preparing file content elsewhere and once ready, atomically making it visible at some named location to other processes. Note that operating systems with an unstable path(true) may relink any hard link to the file to the new location.

Protected Member Functions

 handle (dispatcher *parent, file_flags flags)
virtual void close ()=0
 Calling this directly can cause misoperation. Best to avoid unless you have inspected the source code for the consequences.

Protected Attributes

handle_ptr dirh
atomic< off_t > bytesread
atomic< off_t > byteswritten
atomic< off_t > byteswrittenatlastfsync

Friends

class dispatcher
struct detail::async_io_handle_posix
struct detail::async_io_handle_windows
class detail::async_file_io_dispatcher_compat
class detail::async_file_io_dispatcher_windows
class detail::async_file_io_dispatcher_linux
class detail::async_file_io_dispatcher_qnx

Detailed Description

The abstract base class encapsulating a platform-specific file handle.

Note that failure to explicitly schedule closing a file handle in the dispatcher means it will be synchronously closed on last reference count by handle. This can consume considerable time, especially if SyncOnClose is enabled.

Definition at line 1139 of file afio.hpp.


Member Enumeration Documentation

In which way this handle is opened or not.

Enumerator:
closed 

This handle is closed.

open 

This handle is open as a normal handle.

opendir 

This handle is open as a cached directory handle, and therefore closing it explicitly has no effect.

Definition at line 1165 of file afio.hpp.


Member Function Documentation

virtual void boost::afio::handle::close ( ) [protected, pure virtual]

Calling this directly can cause misoperation. Best to avoid unless you have inspected the source code for the consequences.

Returns the parent of this io handle.

Definition at line 1161 of file afio.hpp.

handle_ptr boost::afio::handle::container ( ) const

Returns a handle to the directory containing this handle. Only works if `file_flags::hold_parent_open` was specified when this handle was opened.

Definition at line 1163 of file afio.hpp.

virtual open_states boost::afio::handle::is_open ( ) const [pure virtual]

Returns if this handle is opened or not.

virtual void* boost::afio::handle::native_handle ( ) const [pure virtual]

Returns the native handle of this io handle. On POSIX, you can cast this to a fd using `(int)(size_t) native_handle()`. On Windows it's a simple `(HANDLE) native_handle()`.

const chrono::system_clock::time_point& boost::afio::handle::opened ( ) const

Returns when this handle was opened.

Definition at line 1176 of file afio.hpp.

virtual boost::afio::path boost::afio::handle::path ( ) const [pure virtual]

Returns the last known good path of this i/o handle. May be null if the file has been deleted.

Returns the final flags used when this handle was opened.

Definition at line 1196 of file afio.hpp.

True if this handle was opened as a file.

Definition at line 1198 of file afio.hpp.

True if this handle was opened as a directory.

Definition at line 1200 of file afio.hpp.

True if this handle was opened as a symlink.

Definition at line 1202 of file afio.hpp.

True if this handle is used by the directory handle cache (not UniqueDirectoryHandle and is open for write and not open for write)

Definition at line 1204 of file afio.hpp.

Returns how many bytes have been read since this handle was opened.

Definition at line 1206 of file afio.hpp.

Returns how many bytes have been written since this handle was opened.

Definition at line 1208 of file afio.hpp.

Returns how many bytes have been written since this handle was last fsynced.

Definition at line 1210 of file afio.hpp.

Returns a mostly filled stat_t structure for the file or directory referenced by this handle. Use `metadata_flags::All` if you want it as complete as your platform allows, even at the cost of severe performance loss. Calls direntry(), so same race guarantees as that call.

Related types: `__afio_directory_entry__`, `__afio_stat_t__`

Definition at line 1229 of file afio.hpp.

virtual mapped_file_ptr boost::afio::handle::map_file ( size_t  length = (size_t)-1,
off_t  offset = 0,
bool  read_only = false 
) [virtual]

Maps the file into memory, returning a null pointer if couldn't map (e.g. address space exhaustion). Do NOT mix this with `file_flags::os_direct`!

Definition at line 1264 of file afio.hpp.


January, 2014

Copyright © 2013-2014 Niall Douglas, Cork, Ireland
Copyright © 2013 Paul Kirth, California
Documentation is generated by Doxygen