mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
In file.hpp, added write_binary_list() method.
This commit is contained in:
parent
3e42c09790
commit
d0dcfe759c
@ -163,6 +163,21 @@ namespace openvpn {
|
||||
OPENVPN_THROW(open_file_error, "cannot write: " << filename);
|
||||
}
|
||||
|
||||
// Write binary buffer list to file
|
||||
template <typename BUFLIST>
|
||||
inline void write_binary_list(const std::string& filename, const BUFLIST& buflist)
|
||||
{
|
||||
std::ofstream ofs(filename.c_str(), std::ios::binary);
|
||||
if (!ofs)
|
||||
OPENVPN_THROW(open_file_error, "cannot open for write: " << filename);
|
||||
for (auto &buf : buflist)
|
||||
{
|
||||
ofs.write((const char *)buf->c_data(), buf->size());
|
||||
if (!ofs)
|
||||
OPENVPN_THROW(open_file_error, "cannot write: " << filename);
|
||||
}
|
||||
}
|
||||
|
||||
// Write std::string to file
|
||||
inline void write_string(const std::string& filename, const std::string& str)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user