Skip to content

Commit b6f5eee

Browse files
committed
file_stdio uses _wfopen_s when _WIN32 is defined
1 parent 33a644f commit b6f5eee

3 files changed

Lines changed: 11 additions & 44 deletions

File tree

src/file_stdio.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ open(char const* path, file_mode mode,
8585
f_ = nullptr;
8686
}
8787
ec = {};
88-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
88+
#ifdef _WIN32
8989
boost::winapi::WCHAR_ const* s;
9090
detail::win32_unicode_path unicode_path(path, ec);
9191
if (ec)
@@ -97,23 +97,23 @@ open(char const* path, file_mode mode,
9797
{
9898
default:
9999
case file_mode::read:
100-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
100+
#ifdef _WIN32
101101
s = L"rb";
102102
#else
103103
s = "rb";
104104
#endif
105105
break;
106106

107107
case file_mode::scan:
108-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
108+
#ifdef _WIN32
109109
s = L"rbS";
110110
#else
111111
s = "rb";
112112
#endif
113113
break;
114114

115115
case file_mode::write:
116-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
116+
#ifdef _WIN32
117117
s = L"wb+";
118118
#else
119119
s = "wb+";
@@ -122,7 +122,7 @@ open(char const* path, file_mode mode,
122122

123123
case file_mode::write_new:
124124
{
125-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
125+
#ifdef _WIN32
126126
# if (defined(BOOST_MSVC) && BOOST_MSVC >= 1910) || (defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION >= 141)
127127
s = L"wbx";
128128
# else
@@ -151,15 +151,15 @@ open(char const* path, file_mode mode,
151151
}
152152

153153
case file_mode::write_existing:
154-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
154+
#ifdef _WIN32
155155
s = L"rb+";
156156
#else
157157
s = "rb+";
158158
#endif
159159
break;
160160

161161
case file_mode::append:
162-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
162+
#ifdef _WIN32
163163
s = L"ab";
164164
#else
165165
s = "ab";
@@ -168,7 +168,7 @@ open(char const* path, file_mode mode,
168168

169169
case file_mode::append_existing:
170170
{
171-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
171+
#ifdef _WIN32
172172
std::FILE* f0;
173173
auto const ev =
174174
::_wfopen_s(&f0, unicode_path.c_str(), L"rb+");
@@ -189,7 +189,7 @@ open(char const* path, file_mode mode,
189189
}
190190
#endif
191191
std::fclose(f0);
192-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
192+
#ifdef _WIN32
193193
s = L"ab";
194194
#else
195195
s = "ab";
@@ -198,7 +198,7 @@ open(char const* path, file_mode mode,
198198
}
199199
}
200200

201-
#if defined(BOOST_MSVC) || defined(_MSVC_STL_VERSION)
201+
#ifdef _WIN32
202202
auto const ev = ::_wfopen_s(
203203
&f_, unicode_path.c_str(), s);
204204
if(ev)

test/unit/file_stdio.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@
1010
// Test that header file is self-contained.
1111
#include <boost/http_proto/file_stdio.hpp>
1212

13-
#include <boost/config.hpp>
14-
15-
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || \
16-
defined(__CYGWIN__)
17-
#define BOOST_HTTP_PROTO_IS_WIN
18-
#endif
19-
20-
#if defined(BOOST_NO_RTTI) && defined(BOOST_HTTP_PROTO_IS_WIN) && \
21-
defined(BOOST_GCC)
22-
23-
#include <boost/config/pragma_message.hpp>
24-
25-
BOOST_PRAGMA_MESSAGE("skipping file_stdio_ tests for this configuration")
26-
27-
#else
28-
2913
#include "file_test.hpp"
3014
#include "test_suite.hpp"
3115

@@ -38,7 +22,7 @@ class file_stdio_test
3822
void
3923
run()
4024
{
41-
#ifdef BOOST_MSVC
25+
#ifdef _WIN32
4226
test_file<file_stdio, true>();
4327
#else
4428
test_file<file_stdio>();
@@ -51,5 +35,3 @@ TEST_SUITE(
5135
"boost.http_proto.file_stdio");
5236
} // http_proto
5337
} // boost
54-
55-
#endif

test/unit/file_win32.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@
1010
// Test that header file is self-contained.
1111
#include <boost/http_proto/file_win32.hpp>
1212

13-
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || \
14-
defined(__CYGWIN__)
15-
#define BOOST_HTTP_PROTO_IS_WIN
16-
#endif
17-
18-
#if defined(BOOST_NO_RTTI) && defined(BOOST_HTTP_PROTO_IS_WIN) && \
19-
defined(BOOST_GCC)
20-
21-
#include <boost/config/pragma_message.hpp>
22-
23-
BOOST_PRAGMA_MESSAGE("skipping file_win32_ tests for this configuration")
24-
25-
#else
26-
2713
#if BOOST_HTTP_PROTO_USE_WIN32_FILE
2814

2915
#include "file_test.hpp"
@@ -50,4 +36,3 @@ TEST_SUITE(
5036
} // boost
5137

5238
#endif // BOOST_HTTP_PROTO_USE_WIN32_FILE
53-
#endif

0 commit comments

Comments
 (0)