mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
MSVC uses ::fopen_s
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
Version 242:
|
Version 242:
|
||||||
|
|
||||||
* test::stream has deprecated lowest_layer for ssl
|
* test::stream has deprecated lowest_layer for ssl
|
||||||
|
* MSVC use ::fopen_s
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ open(char const* path, file_mode mode, error_code& ec)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::scan:
|
case file_mode::scan:
|
||||||
#if BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
s = "rbS";
|
s = "rbS";
|
||||||
#else
|
#else
|
||||||
s = "rb";
|
s = "rb";
|
||||||
@@ -102,12 +102,12 @@ open(char const* path, file_mode mode, error_code& ec)
|
|||||||
case file_mode::write_new:
|
case file_mode::write_new:
|
||||||
{
|
{
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
auto const f0 = std::fopen(path, "rb");
|
x
|
||||||
if(f0)
|
FILE* f0;
|
||||||
|
auto const ev = ::fopen_s(&f0, path, "rb");
|
||||||
|
if(ev)
|
||||||
{
|
{
|
||||||
std::fclose(f0);
|
ec.assign(ev, generic_category());
|
||||||
ec = make_error_code(
|
|
||||||
errc::file_exists);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s = "wb";
|
s = "wb";
|
||||||
@@ -127,20 +127,31 @@ open(char const* path, file_mode mode, error_code& ec)
|
|||||||
|
|
||||||
case file_mode::append_existing:
|
case file_mode::append_existing:
|
||||||
{
|
{
|
||||||
auto const f0 = std::fopen(path, "rb+");
|
#ifdef BOOST_MSVC
|
||||||
if(! f0)
|
FILE* f0;
|
||||||
|
auto const ev =
|
||||||
|
::fopen_s(&f0, path, "rb+");
|
||||||
|
if(ev)
|
||||||
{
|
{
|
||||||
ec = make_error_code(
|
ec.assign(ev, generic_category());
|
||||||
errc::no_such_file_or_directory);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
auto const f0 =
|
||||||
|
std::fopen(path, "rb+");
|
||||||
|
if(! f0)
|
||||||
|
{
|
||||||
|
ec.assign(errno, generic_category());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
std::fclose(f0);
|
std::fclose(f0);
|
||||||
s = "ab";
|
s = "ab";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
auto const ev = ::fopen_s(&f_, path, s);
|
auto const ev = ::fopen_s(&f_, path, s);
|
||||||
if(ev)
|
if(ev)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user