Use fopen_s on Windows

fix #691
This commit is contained in:
Vinnie Falco
2017-07-28 08:36:46 -07:00
parent 0dc2c9d810
commit 6ab9bd2780
3 changed files with 12 additions and 2 deletions

View File

@ -10,6 +10,7 @@ Version 91:
* Set BOOST_ASIO_NO_DEPRECATED
* Use Asio array optimization in static_buffer_base
* Rename wstest source file
* Use fopen_s on Windows
WebSocket:

View File

@ -10,9 +10,8 @@
#ifndef BOOST_BEAST_CONFIG_HPP
#define BOOST_BEAST_CONFIG_HPP
#include <boost/config.hpp>
// Available to every header
#include <boost/config.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/static_assert.hpp>

View File

@ -96,12 +96,22 @@ open(char const* path, file_mode mode, error_code& ec)
case file_mode::append_new: s = "abx"; break;
case file_mode::append_existing: s = "ab"; break;
}
#if BOOST_MSVC
auto const ev = fopen_s(&f_, path, s);
if(ev)
{
f_ = nullptr;
ec.assign(ev, generic_category());
return;
}
#else
f_ = std::fopen(path, s);
if(! f_)
{
ec.assign(errno, generic_category());
return;
}
#endif
ec.assign(0, ec.category());
}