mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 08:46:51 +08:00
fixing overload
made changes in wrong overload by mistake
This commit is contained in:
parent
5bd9c3981f
commit
1dada12aba
@ -52,22 +52,6 @@ inline DWORD int64_low(int64_t n) noexcept
|
|||||||
return n & 0xffffffff;
|
return n & 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
|
||||||
typename String,
|
|
||||||
typename = typename std::enable_if<
|
|
||||||
std::is_same<typename char_type<String>::type, char>::value
|
|
||||||
>::type
|
|
||||||
> file_handle_type open_file_helper(const String& path, const access_mode mode)
|
|
||||||
{
|
|
||||||
return ::CreateFileA(c_str(path),
|
|
||||||
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
0,
|
|
||||||
OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring s_2_ws(const std::string& s)
|
std::wstring s_2_ws(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s.empty())
|
if (s.empty())
|
||||||
@ -78,13 +62,29 @@ std::wstring s_2_ws(const std::string& s)
|
|||||||
return std::wstring(buf.data(), wide_char_count);
|
return std::wstring(buf.data(), wide_char_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
typename String,
|
||||||
|
typename = typename std::enable_if<
|
||||||
|
std::is_same<typename char_type<String>::type, char>::value
|
||||||
|
>::type
|
||||||
|
> file_handle_type open_file_helper(const String& path, const access_mode mode)
|
||||||
|
{
|
||||||
|
return ::CreateFileW(s_2_ws(path).c_str(),
|
||||||
|
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
0,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename String>
|
template<typename String>
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
std::is_same<typename char_type<String>::type, wchar_t>::value,
|
std::is_same<typename char_type<String>::type, wchar_t>::value,
|
||||||
file_handle_type
|
file_handle_type
|
||||||
>::type open_file_helper(const String& path, const access_mode mode)
|
>::type open_file_helper(const String& path, const access_mode mode)
|
||||||
{
|
{
|
||||||
return ::CreateFileW(s_2_ws(path).c_str(),
|
return ::CreateFileW(c_str(path),
|
||||||
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@ -794,22 +794,6 @@ inline DWORD int64_low(int64_t n) noexcept
|
|||||||
return n & 0xffffffff;
|
return n & 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
|
||||||
typename String,
|
|
||||||
typename = typename std::enable_if<
|
|
||||||
std::is_same<typename char_type<String>::type, char>::value
|
|
||||||
>::type
|
|
||||||
> file_handle_type open_file_helper(const String& path, const access_mode mode)
|
|
||||||
{
|
|
||||||
return ::CreateFileA(c_str(path),
|
|
||||||
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
0,
|
|
||||||
OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring s_2_ws(const std::string& s)
|
std::wstring s_2_ws(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s.empty())
|
if (s.empty())
|
||||||
@ -820,13 +804,29 @@ std::wstring s_2_ws(const std::string& s)
|
|||||||
return std::wstring(buf.data(), wide_char_count);
|
return std::wstring(buf.data(), wide_char_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
typename String,
|
||||||
|
typename = typename std::enable_if<
|
||||||
|
std::is_same<typename char_type<String>::type, char>::value
|
||||||
|
>::type
|
||||||
|
> file_handle_type open_file_helper(const String& path, const access_mode mode)
|
||||||
|
{
|
||||||
|
return ::CreateFileW(s_2_ws(path).c_str(),
|
||||||
|
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
0,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename String>
|
template<typename String>
|
||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
std::is_same<typename char_type<String>::type, wchar_t>::value,
|
std::is_same<typename char_type<String>::type, wchar_t>::value,
|
||||||
file_handle_type
|
file_handle_type
|
||||||
>::type open_file_helper(const String& path, const access_mode mode)
|
>::type open_file_helper(const String& path, const access_mode mode)
|
||||||
{
|
{
|
||||||
return ::CreateFileW(s_2_ws(path).c_str(),
|
return ::CreateFileW(c_str(path),
|
||||||
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
0,
|
0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user