Asio Extensions
Additional functionality built on top of (Boost.)Asio
asioext::open()

Open a handle to a file. More...

Functions

unique_file_handle asioext::open (const char *filename, open_flags flags, file_perms perms=file_perms::create_default, file_attrs attrs=file_attrs::none)
 Open a file and return its handle. More...
 
unique_file_handle asioext::open (const char *filename, open_flags flags, file_perms perms, file_attrs attrs, error_code &ec) noexcept
 Open a file and return its handle. More...
 
unique_file_handle asioext::open (const wchar_t *filename, open_flags flags, file_perms perms=file_perms::create_default, file_attrs attrs=file_attrs::none)
 Open a file and return its handle. More...
 
unique_file_handle asioext::open (const wchar_t *filename, open_flags flags, file_perms perms, file_attrs attrs, error_code &ec) noexcept
 Open a file and return its handle. More...
 
unique_file_handle asioext::open (const boost::filesystem::path &filename, open_flags flags, file_perms perms=file_perms::create_default, file_attrs attrs=file_attrs::none)
 Open a file and return its handle. More...
 
unique_file_handle asioext::open (const boost::filesystem::path &filename, open_flags flags, file_perms perms, file_attrs attrs, error_code &ec) noexcept
 Open a file and return its handle. More...
 

Detailed Description

Open a handle to a file.

Function Documentation

◆ open() [1/6]

unique_file_handle asioext::open ( const char *  filename,
open_flags  flags,
file_perms  perms = file_perms::create_default,
file_attrs  attrs = file_attrs::none 
)

Open a file and return its handle.

This function opens the specified file and returns a handle to it.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
Returns
A handle to the opened file. Ownership is transferred to the caller. Handles are not inherited by child processes.
Exceptions
asio::system_errorThrown on failure.
See also
open_flags
Filenames

◆ open() [2/6]

unique_file_handle asioext::open ( const char *  filename,
open_flags  flags,
file_perms  perms,
file_attrs  attrs,
error_code ec 
)
noexcept

Open a file and return its handle.

This function attempts to open the specified file. If successful, the returned file_handle will contain the handle of the opened file. Otherwise the file_handle will be empty.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Returns
A handle to the opened file (or an empty handle in case of failure). Ownership is transferred to the caller. Handles are not inherited by child processes.
See also
open_flags
Filenames

◆ open() [3/6]

unique_file_handle asioext::open ( const wchar_t *  filename,
open_flags  flags,
file_perms  perms = file_perms::create_default,
file_attrs  attrs = file_attrs::none 
)

Open a file and return its handle.

This function opens the specified file and returns a handle to it.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
Returns
A handle to the opened file. Ownership is transferred to the caller. Handles are not inherited by child processes.
Exceptions
asio::system_errorThrown on failure.
See also
open_flags
Filenames
Note
Only available on Windows.

◆ open() [4/6]

unique_file_handle asioext::open ( const wchar_t *  filename,
open_flags  flags,
file_perms  perms,
file_attrs  attrs,
error_code ec 
)
noexcept

Open a file and return its handle.

This function attempts to open the specified file. If successful, the returned file_handle will contain the handle of the opened file. Otherwise the file_handle will be empty.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Returns
A handle to the opened file (or an empty handle in case of failure). Ownership is transferred to the caller. Handles are not inherited by child processes.
See also
open_flags
Filenames
Note
Only available on Windows.

◆ open() [5/6]

unique_file_handle asioext::open ( const boost::filesystem::path &  filename,
open_flags  flags,
file_perms  perms = file_perms::create_default,
file_attrs  attrs = file_attrs::none 
)

Open a file and return its handle.

This function opens the specified file and returns a handle to it.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
Returns
A handle to the opened file. Ownership is transferred to the caller. Handles are not inherited by child processes.
Exceptions
asio::system_errorThrown on failure.
See also
open_flags
Filenames
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)

◆ open() [6/6]

unique_file_handle asioext::open ( const boost::filesystem::path &  filename,
open_flags  flags,
file_perms  perms,
file_attrs  attrs,
error_code ec 
)
noexcept

Open a file and return its handle.

This function attempts to open the specified file. If successful, the returned file_handle will contain the handle of the opened file. Otherwise the file_handle will be empty.

Parameters
filenameThe path of the file to open. See Filenames for details.
flagsFlags used to open the file. For a detailed reference, see asioext::open_flags.
permsPermissions for newly created files. Unused if an existing file is opened. Defaults to file_perms::create_default.
attrsAttributes for newly created files. Unused if an existing file is opened. Defaults to file_attrs::none.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Returns
A handle to the opened file (or an empty handle in case of failure). Ownership is transferred to the caller. Handles are not inherited by child processes.
See also
open_flags
Filenames
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)