]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/filesystem/src/windows_file_codecvt.cpp
1 // filesystem windows_file_codecvt.cpp -----------------------------------------//
3 // Copyright Beman Dawes 2009
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 // Library home page: http://www.boost.org/libs/filesystem
10 //--------------------------------------------------------------------------------------//
12 // define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
13 // the library is being built (possibly exporting rather than importing code)
14 #define BOOST_FILESYSTEM_SOURCE
16 #ifndef BOOST_SYSTEM_NO_DEPRECATED
17 # define BOOST_SYSTEM_NO_DEPRECATED
20 #include <boost/filesystem/config.hpp>
21 #include <cwchar> // for mbstate_t
23 #ifdef BOOST_WINDOWS_API
25 #include "windows_file_codecvt.hpp"
27 // Versions of MinGW prior to GCC 4.6 requires this
29 # define WINVER 0x0500
34 std::codecvt_base::result
windows_file_codecvt::do_in(
36 const char* from
, const char* from_end
, const char*& from_next
,
37 wchar_t* to
, wchar_t* to_end
, wchar_t*& to_next
) const
39 UINT codepage
= AreFileApisANSI() ? CP_ACP
: CP_OEMCP
;
42 if ((count
= ::MultiByteToWideChar(codepage
, MB_PRECOMPOSED
, from
,
43 from_end
- from
, to
, to_end
- to
)) == 0)
45 return error
; // conversion failed
54 std::codecvt_base::result
windows_file_codecvt::do_out(
56 const wchar_t* from
, const wchar_t* from_end
, const wchar_t* & from_next
,
57 char* to
, char* to_end
, char* & to_next
) const
59 UINT codepage
= AreFileApisANSI() ? CP_ACP
: CP_OEMCP
;
62 if ((count
= ::WideCharToMultiByte(codepage
, WC_NO_BEST_FIT_CHARS
, from
,
63 from_end
- from
, to
, to_end
- to
, 0, 0)) == 0)
65 return error
; // conversion failed
74 # endif // BOOST_WINDOWS_API