]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/nowide/src/cstdio.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / nowide / src / cstdio.cpp
CommitLineData
f67539c2
TL
1//
2// Copyright (c) 2012 Artyom Beilis (Tonkikh)
1e59de90 3// Copyright (c) 2020-2022 Alexander Grund
f67539c2
TL
4//
5// Distributed under the Boost Software License, Version 1.0. (See
20effc67 6// accompanying file LICENSE or copy at
f67539c2
TL
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
10#define BOOST_NOWIDE_SOURCE
11
12#ifdef _MSC_VER
13#define _CRT_SECURE_NO_WARNINGS
1e59de90
TL
14#elif defined(__MINGW32__) && defined(__STRICT_ANSI__)
15// Need the _w* functions which are extensions on MinGW but not on MinGW-w64
16#include <_mingw.h>
17#ifndef __MINGW64_VERSION_MAJOR
f67539c2
TL
18#undef __STRICT_ANSI__
19#endif
1e59de90 20#endif
f67539c2
TL
21
22#include <boost/nowide/cstdio.hpp>
23#include <boost/nowide/stackstring.hpp>
24
25namespace boost {
26namespace nowide {
27 namespace detail {
28 FILE* wfopen(const wchar_t* filename, const wchar_t* mode)
29 {
30#ifdef BOOST_WINDOWS
1e59de90 31 // coverity[var_deref_model]
f67539c2
TL
32 return ::_wfopen(filename, mode);
33#else
34 const stackstring name(filename);
35 const short_stackstring smode2(mode);
36 return std::fopen(name.get(), smode2.get());
37#endif
38 }
39 } // namespace detail
40
41#ifdef BOOST_WINDOWS
42 ///
43 /// \brief Same as freopen but file_name and mode are UTF-8 strings
44 ///
45 FILE* freopen(const char* file_name, const char* mode, FILE* stream)
46 {
47 const wstackstring wname(file_name);
48 const wshort_stackstring wmode(mode);
1e59de90 49 // coverity[var_deref_model]
f67539c2
TL
50 return _wfreopen(wname.get(), wmode.get(), stream);
51 }
52 ///
53 /// \brief Same as fopen but file_name and mode are UTF-8 strings
54 ///
55 FILE* fopen(const char* file_name, const char* mode)
56 {
57 const wstackstring wname(file_name);
58 const wshort_stackstring wmode(mode);
1e59de90
TL
59 // coverity[var_deref_model]
60 return detail::wfopen(wname.get(), wmode.get());
f67539c2
TL
61 }
62 ///
63 /// \brief Same as rename but old_name and new_name are UTF-8 strings
64 ///
65 int rename(const char* old_name, const char* new_name)
66 {
67 const wstackstring wold(old_name), wnew(new_name);
68 return _wrename(wold.get(), wnew.get());
69 }
70 ///
71 /// \brief Same as rename but name is UTF-8 string
72 ///
73 int remove(const char* name)
74 {
75 const wstackstring wname(name);
76 return _wremove(wname.get());
77 }
78#endif
79} // namespace nowide
80} // namespace boost