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

RawByteContainer overloads

See RawByteContainer for RawByteContainer requirements.

template<class RawByteContainer >
void asioext::read_file (const char *filename, RawByteContainer &c)
 
template<class RawByteContainer >
void asioext::read_file (const char *filename, RawByteContainer &c, error_code &ec)
 
template<class RawByteContainer >
void asioext::read_file (const wchar_t *filename, RawByteContainer &c)
 
template<class RawByteContainer >
void asioext::read_file (const wchar_t *filename, RawByteContainer &c, error_code &ec)
 
template<class RawByteContainer >
void asioext::read_file (const boost::filesystem::path &filename, RawByteContainer &c)
 
template<class RawByteContainer >
void asioext::read_file (const boost::filesystem::path &filename, RawByteContainer &c, error_code &ec)
 
template<class RawByteContainer >
void asioext::read_file (file_handle file, RawByteContainer &c)
 
template<class RawByteContainer >
void asioext::read_file (file_handle file, RawByteContainer &c, error_code &ec) noexcept
 

MutableBufferSequence overloads

template<class MutableBufferSequence >
void asioext::read_file (const char *filename, const MutableBufferSequence &buffers)
 
template<class MutableBufferSequence >
void asioext::read_file (const char *filename, const MutableBufferSequence &buffers, error_code &ec) noexcept
 
template<class MutableBufferSequence >
void asioext::read_file (const wchar_t *filename, const MutableBufferSequence &buffers)
 
template<class MutableBufferSequence >
void asioext::read_file (const wchar_t *filename, const MutableBufferSequence &buffers, error_code &ec) noexcept
 
template<class MutableBufferSequence >
void asioext::read_file (const boost::filesystem::path &filename, const MutableBufferSequence &buffers)
 
template<class MutableBufferSequence >
void asioext::read_file (const boost::filesystem::path &filename, const MutableBufferSequence &buffers, error_code &ec) noexcept
 
template<class MutableBufferSequence >
void asioext::read_file (file_handle file, const MutableBufferSequence &buffers)
 
template<class MutableBufferSequence >
void asioext::read_file (file_handle file, const MutableBufferSequence &buffers, error_code &ec) noexcept
 

Detailed Description

Reads the entire contents of a file into memory.

Function Documentation

◆ read_file() [1/16]

template<class RawByteContainer >
void asioext::read_file ( const char *  filename,
RawByteContainer &  c 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
Exceptions
asio::system_errorThrown on failure.

◆ read_file() [2/16]

template<class RawByteContainer >
void asioext::read_file ( const char *  filename,
RawByteContainer &  c,
error_code ec 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
ecSet to indicate what error occurred. If no error occurred, the object is reset.

◆ read_file() [3/16]

template<class RawByteContainer >
void asioext::read_file ( const wchar_t *  filename,
RawByteContainer &  c 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
Exceptions
asio::system_errorThrown on failure.
Note
Only available on Windows.

◆ read_file() [4/16]

template<class RawByteContainer >
void asioext::read_file ( const wchar_t *  filename,
RawByteContainer &  c,
error_code ec 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Note
Only available on Windows.

◆ read_file() [5/16]

template<class RawByteContainer >
void asioext::read_file ( const boost::filesystem::path &  filename,
RawByteContainer &  c 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
Exceptions
asio::system_errorThrown on failure.
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)

◆ read_file() [6/16]

template<class RawByteContainer >
void asioext::read_file ( const boost::filesystem::path &  filename,
RawByteContainer &  c,
error_code ec 
)

Read a file into a container.

This function loads the contents of filename into c.

Parameters
filenameThe path of the file to load.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)

◆ read_file() [7/16]

template<class RawByteContainer >
void asioext::read_file ( file_handle  file,
RawByteContainer &  c 
)

Read a file into a container.

This function loads the contents of file into c.

Parameters
fileThe file_handle object to read from. The file_handle's file pointer is expected to point at the beginning of the file. Upon completion, the file pointer points at the end.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
Exceptions
asio::system_errorThrown on failure.

◆ read_file() [8/16]

template<class RawByteContainer >
void asioext::read_file ( file_handle  file,
RawByteContainer &  c,
error_code ec 
)
noexcept

Read a file into a container.

This function loads the contents of file into c.

Parameters
fileThe file_handle object to read from. The file_handle's file pointer is expected to point at the beginning of the file. Upon completion, the file pointer points at the end.
cThe container object which shall contain the file's content. The container is resized to the file's size and any previous data is overwritten. The container type must satisfy the RawByteContainer requirements.
ecSet to indicate what error occurred. If no error occurred, the object is reset.

◆ read_file() [9/16]

template<class MutableBufferSequence >
void asioext::read_file ( const char *  filename,
const MutableBufferSequence buffers 
)

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
Exceptions
asio::system_errorThrown on failure.

◆ read_file() [10/16]

template<class MutableBufferSequence >
void asioext::read_file ( const char *  filename,
const MutableBufferSequence buffers,
error_code ec 
)
noexcept

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
ecSet to indicate what error occurred. If no error occurred, the object is reset.

◆ read_file() [11/16]

template<class MutableBufferSequence >
void asioext::read_file ( const wchar_t *  filename,
const MutableBufferSequence buffers 
)

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
Exceptions
asio::system_errorThrown on failure.
Note
Only available on Windows.

◆ read_file() [12/16]

template<class MutableBufferSequence >
void asioext::read_file ( const wchar_t *  filename,
const MutableBufferSequence buffers,
error_code ec 
)
noexcept

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Note
Only available on Windows.

◆ read_file() [13/16]

template<class MutableBufferSequence >
void asioext::read_file ( const boost::filesystem::path &  filename,
const MutableBufferSequence buffers 
)

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
Exceptions
asio::system_errorThrown on failure.
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)

◆ read_file() [14/16]

template<class MutableBufferSequence >
void asioext::read_file ( const boost::filesystem::path &  filename,
const MutableBufferSequence buffers,
error_code ec 
)
noexcept

Read a file into a sequence of buffers.

This function loads the contents of filename into buffers.

Parameters
filenameThe path of the file to load.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
ecSet to indicate what error occurred. If no error occurred, the object is reset.
Note
Only available if using Boost.Filesystem (i.e. if ASIOEXT_HAS_BOOST_FILESYSTEM is defined)

◆ read_file() [15/16]

template<class MutableBufferSequence >
void asioext::read_file ( file_handle  file,
const MutableBufferSequence buffers 
)

Read a file into a sequence of buffers.

This function loads the contents of file into c.

Parameters
fileThe file_handle object to read from. The file_handle's file pointer is expected to point at the beginning of the file. Upon completion, the file pointer points at the end.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
Exceptions
asio::system_errorThrown on failure.

◆ read_file() [16/16]

template<class MutableBufferSequence >
void asioext::read_file ( file_handle  file,
const MutableBufferSequence buffers,
error_code ec 
)
noexcept

Read a file into a sequence of buffers.

This function loads the contents of file into c.

Parameters
fileThe file_handle object to read from. The file_handle's file pointer is expected to point at the beginning of the file. Upon completion, the file pointer points at the end.
buffersThe sequence of buffers to read the file into. If the file size is less than the total size of all buffers, the call will fail. Otherwise the buffer is filled entirely. Trailing data is ignored.
ecSet to indicate what error occurred. If no error occurred, the object is reset.