mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +02:00
Update Boost.WinAPI usage to the new location and namespace.
This commit is contained in:
committed by
Vinnie Falco
parent
645fdb6581
commit
ab2a225a9a
@ -9,6 +9,7 @@ Version 126:
|
|||||||
* Fix shadowing in session_alloc
|
* Fix shadowing in session_alloc
|
||||||
* Fix executor type compilation
|
* Fix executor type compilation
|
||||||
* Add Travis tests with the default compilers
|
* Add Travis tests with the default compilers
|
||||||
|
* Update Boost.WinAPI usage to the new location and namespace.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/core/file_base.hpp>
|
#include <boost/beast/core/file_base.hpp>
|
||||||
#include <boost/detail/winapi/basic_types.hpp>
|
#include <boost/winapi/basic_types.hpp>
|
||||||
#include <boost/detail/winapi/handles.hpp>
|
#include <boost/winapi/handles.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ namespace beast {
|
|||||||
*/
|
*/
|
||||||
class file_win32
|
class file_win32
|
||||||
{
|
{
|
||||||
boost::detail::winapi::HANDLE_ h_ =
|
boost::winapi::HANDLE_ h_ =
|
||||||
boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** The type of the underlying file handle.
|
/** The type of the underlying file handle.
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
#if BOOST_BEAST_DOXYGEN
|
#if BOOST_BEAST_DOXYGEN
|
||||||
using native_handle_type = HANDLE;
|
using native_handle_type = HANDLE;
|
||||||
#else
|
#else
|
||||||
using native_handle_type = boost::detail::winapi::HANDLE_;
|
using native_handle_type = boost::winapi::HANDLE_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Destructor
|
/** Destructor
|
||||||
@ -96,7 +96,7 @@ public:
|
|||||||
bool
|
bool
|
||||||
is_open() const
|
is_open() const
|
||||||
{
|
{
|
||||||
return h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
return h_ != boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Close the file if open
|
/** Close the file if open
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||||
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||||
|
|
||||||
#include <boost/detail/winapi/access_rights.hpp>
|
#include <boost/winapi/access_rights.hpp>
|
||||||
#include <boost/detail/winapi/error_codes.hpp>
|
#include <boost/winapi/error_codes.hpp>
|
||||||
#include <boost/detail/winapi/file_management.hpp>
|
#include <boost/winapi/file_management.hpp>
|
||||||
#include <boost/detail/winapi/get_last_error.hpp>
|
#include <boost/winapi/get_last_error.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -25,20 +25,20 @@ namespace detail {
|
|||||||
// VFALCO Can't seem to get boost/detail/winapi to work with
|
// VFALCO Can't seem to get boost/detail/winapi to work with
|
||||||
// this so use the non-Ex version for now.
|
// this so use the non-Ex version for now.
|
||||||
inline
|
inline
|
||||||
boost::detail::winapi::BOOL_
|
boost::winapi::BOOL_
|
||||||
set_file_pointer_ex(
|
set_file_pointer_ex(
|
||||||
boost::detail::winapi::HANDLE_ hFile,
|
boost::winapi::HANDLE_ hFile,
|
||||||
boost::detail::winapi::LARGE_INTEGER_ lpDistanceToMove,
|
boost::winapi::LARGE_INTEGER_ lpDistanceToMove,
|
||||||
boost::detail::winapi::PLARGE_INTEGER_ lpNewFilePointer,
|
boost::winapi::PLARGE_INTEGER_ lpNewFilePointer,
|
||||||
boost::detail::winapi::DWORD_ dwMoveMethod)
|
boost::winapi::DWORD_ dwMoveMethod)
|
||||||
{
|
{
|
||||||
auto dwHighPart = lpDistanceToMove.u.HighPart;
|
auto dwHighPart = lpDistanceToMove.u.HighPart;
|
||||||
auto dwLowPart = boost::detail::winapi::SetFilePointer(
|
auto dwLowPart = boost::winapi::SetFilePointer(
|
||||||
hFile,
|
hFile,
|
||||||
lpDistanceToMove.u.LowPart,
|
lpDistanceToMove.u.LowPart,
|
||||||
&dwHighPart,
|
&dwHighPart,
|
||||||
dwMoveMethod);
|
dwMoveMethod);
|
||||||
if(dwLowPart == boost::detail::winapi::INVALID_SET_FILE_POINTER_)
|
if(dwLowPart == boost::winapi::INVALID_SET_FILE_POINTER_)
|
||||||
return 0;
|
return 0;
|
||||||
if(lpNewFilePointer)
|
if(lpNewFilePointer)
|
||||||
{
|
{
|
||||||
@ -54,8 +54,8 @@ inline
|
|||||||
file_win32::
|
file_win32::
|
||||||
~file_win32()
|
~file_win32()
|
||||||
{
|
{
|
||||||
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
boost::detail::winapi::CloseHandle(h_);
|
boost::winapi::CloseHandle(h_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@ -63,7 +63,7 @@ file_win32::
|
|||||||
file_win32(file_win32&& other)
|
file_win32(file_win32&& other)
|
||||||
: h_(other.h_)
|
: h_(other.h_)
|
||||||
{
|
{
|
||||||
other.h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
other.h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@ -74,9 +74,9 @@ operator=(file_win32&& other)
|
|||||||
if(&other == this)
|
if(&other == this)
|
||||||
return *this;
|
return *this;
|
||||||
if(h_)
|
if(h_)
|
||||||
boost::detail::winapi::CloseHandle(h_);
|
boost::winapi::CloseHandle(h_);
|
||||||
h_ = other.h_;
|
h_ = other.h_;
|
||||||
other.h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
other.h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ void
|
|||||||
file_win32::
|
file_win32::
|
||||||
native_handle(native_handle_type h)
|
native_handle(native_handle_type h)
|
||||||
{
|
{
|
||||||
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
boost::detail::winapi::CloseHandle(h_);
|
boost::winapi::CloseHandle(h_);
|
||||||
h_ = h;
|
h_ = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,14 +95,14 @@ void
|
|||||||
file_win32::
|
file_win32::
|
||||||
close(error_code& ec)
|
close(error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
if(! boost::detail::winapi::CloseHandle(h_))
|
if(! boost::winapi::CloseHandle(h_))
|
||||||
ec.assign(boost::detail::winapi::GetLastError(),
|
ec.assign(boost::winapi::GetLastError(),
|
||||||
system_category());
|
system_category());
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec.assign(0, ec.category());
|
||||||
h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -115,15 +115,15 @@ void
|
|||||||
file_win32::
|
file_win32::
|
||||||
open(char const* path, file_mode mode, error_code& ec)
|
open(char const* path, file_mode mode, error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
boost::detail::winapi::CloseHandle(h_);
|
boost::winapi::CloseHandle(h_);
|
||||||
h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
|
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
||||||
}
|
}
|
||||||
boost::detail::winapi::DWORD_ share_mode = 0;
|
boost::winapi::DWORD_ share_mode = 0;
|
||||||
boost::detail::winapi::DWORD_ desired_access = 0;
|
boost::winapi::DWORD_ desired_access = 0;
|
||||||
boost::detail::winapi::DWORD_ creation_disposition = 0;
|
boost::winapi::DWORD_ creation_disposition = 0;
|
||||||
boost::detail::winapi::DWORD_ flags_and_attributes = 0;
|
boost::winapi::DWORD_ flags_and_attributes = 0;
|
||||||
/*
|
/*
|
||||||
| When the file...
|
| When the file...
|
||||||
This argument: | Exists Does not exist
|
This argument: | Exists Does not exist
|
||||||
@ -138,59 +138,59 @@ open(char const* path, file_mode mode, error_code& ec)
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case file_mode::read:
|
case file_mode::read:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_;
|
desired_access = boost::winapi::GENERIC_READ_;
|
||||||
share_mode = boost::detail::winapi::FILE_SHARE_READ_;
|
share_mode = boost::winapi::FILE_SHARE_READ_;
|
||||||
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
|
creation_disposition = boost::winapi::OPEN_EXISTING_;
|
||||||
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::scan:
|
case file_mode::scan:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_;
|
desired_access = boost::winapi::GENERIC_READ_;
|
||||||
share_mode = boost::detail::winapi::FILE_SHARE_READ_;
|
share_mode = boost::winapi::FILE_SHARE_READ_;
|
||||||
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
|
creation_disposition = boost::winapi::OPEN_EXISTING_;
|
||||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::write:
|
case file_mode::write:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
creation_disposition = boost::detail::winapi::CREATE_ALWAYS_;
|
creation_disposition = boost::winapi::CREATE_ALWAYS_;
|
||||||
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::write_new:
|
case file_mode::write_new:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
creation_disposition = boost::detail::winapi::CREATE_NEW_;
|
creation_disposition = boost::winapi::CREATE_NEW_;
|
||||||
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::write_existing:
|
case file_mode::write_existing:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
|
creation_disposition = boost::winapi::OPEN_EXISTING_;
|
||||||
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::append:
|
case file_mode::append:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
|
|
||||||
creation_disposition = boost::detail::winapi::CREATE_ALWAYS_;
|
creation_disposition = boost::winapi::CREATE_ALWAYS_;
|
||||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::append_new:
|
case file_mode::append_new:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
creation_disposition = boost::detail::winapi::CREATE_NEW_;
|
creation_disposition = boost::winapi::CREATE_NEW_;
|
||||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case file_mode::append_existing:
|
case file_mode::append_existing:
|
||||||
desired_access = boost::detail::winapi::GENERIC_READ_ |
|
desired_access = boost::winapi::GENERIC_READ_ |
|
||||||
boost::detail::winapi::GENERIC_WRITE_;
|
boost::winapi::GENERIC_WRITE_;
|
||||||
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
|
creation_disposition = boost::winapi::OPEN_EXISTING_;
|
||||||
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -202,8 +202,8 @@ open(char const* path, file_mode mode, error_code& ec)
|
|||||||
creation_disposition,
|
creation_disposition,
|
||||||
flags_and_attributes,
|
flags_and_attributes,
|
||||||
NULL);
|
NULL);
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
ec.assign(boost::detail::winapi::GetLastError(),
|
ec.assign(boost::winapi::GetLastError(),
|
||||||
system_category());
|
system_category());
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec.assign(0, ec.category());
|
||||||
@ -214,15 +214,15 @@ std::uint64_t
|
|||||||
file_win32::
|
file_win32::
|
||||||
size(error_code& ec) const
|
size(error_code& ec) const
|
||||||
{
|
{
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec.assign(errc::invalid_argument, generic_category());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
boost::detail::winapi::LARGE_INTEGER_ fileSize;
|
boost::winapi::LARGE_INTEGER_ fileSize;
|
||||||
if(! boost::detail::winapi::GetFileSizeEx(h_, &fileSize))
|
if(! boost::winapi::GetFileSizeEx(h_, &fileSize))
|
||||||
{
|
{
|
||||||
ec.assign(boost::detail::winapi::GetLastError(),
|
ec.assign(boost::winapi::GetLastError(),
|
||||||
system_category());
|
system_category());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -235,18 +235,18 @@ std::uint64_t
|
|||||||
file_win32::
|
file_win32::
|
||||||
pos(error_code& ec)
|
pos(error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec.assign(errc::invalid_argument, generic_category());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
boost::detail::winapi::LARGE_INTEGER_ in;
|
boost::winapi::LARGE_INTEGER_ in;
|
||||||
boost::detail::winapi::LARGE_INTEGER_ out;
|
boost::winapi::LARGE_INTEGER_ out;
|
||||||
in.QuadPart = 0;
|
in.QuadPart = 0;
|
||||||
if(! detail::set_file_pointer_ex(h_, in, &out,
|
if(! detail::set_file_pointer_ex(h_, in, &out,
|
||||||
boost::detail::winapi::FILE_CURRENT_))
|
boost::winapi::FILE_CURRENT_))
|
||||||
{
|
{
|
||||||
ec.assign(boost::detail::winapi::GetLastError(),
|
ec.assign(boost::winapi::GetLastError(),
|
||||||
system_category());
|
system_category());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -259,17 +259,17 @@ void
|
|||||||
file_win32::
|
file_win32::
|
||||||
seek(std::uint64_t offset, error_code& ec)
|
seek(std::uint64_t offset, error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec.assign(errc::invalid_argument, generic_category());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boost::detail::winapi::LARGE_INTEGER_ in;
|
boost::winapi::LARGE_INTEGER_ in;
|
||||||
in.QuadPart = offset;
|
in.QuadPart = offset;
|
||||||
if(! detail::set_file_pointer_ex(h_, in, 0,
|
if(! detail::set_file_pointer_ex(h_, in, 0,
|
||||||
boost::detail::winapi::FILE_BEGIN_))
|
boost::winapi::FILE_BEGIN_))
|
||||||
{
|
{
|
||||||
ec.assign(boost::detail::winapi::GetLastError(),
|
ec.assign(boost::winapi::GetLastError(),
|
||||||
system_category());
|
system_category());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ std::size_t
|
|||||||
file_win32::
|
file_win32::
|
||||||
read(void* buffer, std::size_t n, error_code& ec)
|
read(void* buffer, std::size_t n, error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec.assign(errc::invalid_argument, generic_category());
|
||||||
return 0;
|
return 0;
|
||||||
@ -289,19 +289,19 @@ read(void* buffer, std::size_t n, error_code& ec)
|
|||||||
std::size_t nread = 0;
|
std::size_t nread = 0;
|
||||||
while(n > 0)
|
while(n > 0)
|
||||||
{
|
{
|
||||||
boost::detail::winapi::DWORD_ amount;
|
boost::winapi::DWORD_ amount;
|
||||||
if(n > (std::numeric_limits<
|
if(n > (std::numeric_limits<
|
||||||
boost::detail::winapi::DWORD_>::max)())
|
boost::winapi::DWORD_>::max)())
|
||||||
amount = (std::numeric_limits<
|
amount = (std::numeric_limits<
|
||||||
boost::detail::winapi::DWORD_>::max)();
|
boost::winapi::DWORD_>::max)();
|
||||||
else
|
else
|
||||||
amount = static_cast<
|
amount = static_cast<
|
||||||
boost::detail::winapi::DWORD_>(n);
|
boost::winapi::DWORD_>(n);
|
||||||
boost::detail::winapi::DWORD_ bytesRead;
|
boost::winapi::DWORD_ bytesRead;
|
||||||
if(! ::ReadFile(h_, buffer, amount, &bytesRead, 0))
|
if(! ::ReadFile(h_, buffer, amount, &bytesRead, 0))
|
||||||
{
|
{
|
||||||
auto const dwError = ::GetLastError();
|
auto const dwError = ::GetLastError();
|
||||||
if(dwError != boost::detail::winapi::ERROR_HANDLE_EOF_)
|
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
|
||||||
ec.assign(::GetLastError(), system_category());
|
ec.assign(::GetLastError(), system_category());
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec.assign(0, ec.category());
|
||||||
@ -322,7 +322,7 @@ std::size_t
|
|||||||
file_win32::
|
file_win32::
|
||||||
write(void const* buffer, std::size_t n, error_code& ec)
|
write(void const* buffer, std::size_t n, error_code& ec)
|
||||||
{
|
{
|
||||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec.assign(errc::invalid_argument, generic_category());
|
||||||
return 0;
|
return 0;
|
||||||
@ -330,19 +330,19 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
|||||||
std::size_t nwritten = 0;
|
std::size_t nwritten = 0;
|
||||||
while(n > 0)
|
while(n > 0)
|
||||||
{
|
{
|
||||||
boost::detail::winapi::DWORD_ amount;
|
boost::winapi::DWORD_ amount;
|
||||||
if(n > (std::numeric_limits<
|
if(n > (std::numeric_limits<
|
||||||
boost::detail::winapi::DWORD_>::max)())
|
boost::winapi::DWORD_>::max)())
|
||||||
amount = (std::numeric_limits<
|
amount = (std::numeric_limits<
|
||||||
boost::detail::winapi::DWORD_>::max)();
|
boost::winapi::DWORD_>::max)();
|
||||||
else
|
else
|
||||||
amount = static_cast<
|
amount = static_cast<
|
||||||
boost::detail::winapi::DWORD_>(n);
|
boost::winapi::DWORD_>(n);
|
||||||
boost::detail::winapi::DWORD_ bytesWritten;
|
boost::winapi::DWORD_ bytesWritten;
|
||||||
if(! ::WriteFile(h_, buffer, amount, &bytesWritten, 0))
|
if(! ::WriteFile(h_, buffer, amount, &bytesWritten, 0))
|
||||||
{
|
{
|
||||||
auto const dwError = ::GetLastError();
|
auto const dwError = ::GetLastError();
|
||||||
if(dwError != boost::detail::winapi::ERROR_HANDLE_EOF_)
|
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
|
||||||
ec.assign(::GetLastError(), system_category());
|
ec.assign(::GetLastError(), system_category());
|
||||||
else
|
else
|
||||||
ec.assign(0, ec.category());
|
ec.assign(0, ec.category());
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <boost/asio/windows/overlapped_ptr.hpp>
|
#include <boost/asio/windows/overlapped_ptr.hpp>
|
||||||
#include <boost/make_unique.hpp>
|
#include <boost/make_unique.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared_array.hpp>
|
||||||
#include <boost/detail/winapi/basic_types.hpp>
|
#include <boost/winapi/basic_types.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -279,27 +279,27 @@ namespace detail {
|
|||||||
|
|
||||||
template<class Unsigned>
|
template<class Unsigned>
|
||||||
inline
|
inline
|
||||||
boost::detail::winapi::DWORD_
|
boost::winapi::DWORD_
|
||||||
lowPart(Unsigned n)
|
lowPart(Unsigned n)
|
||||||
{
|
{
|
||||||
return static_cast<
|
return static_cast<
|
||||||
boost::detail::winapi::DWORD_>(
|
boost::winapi::DWORD_>(
|
||||||
n & 0xffffffff);
|
n & 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Unsigned>
|
template<class Unsigned>
|
||||||
inline
|
inline
|
||||||
boost::detail::winapi::DWORD_
|
boost::winapi::DWORD_
|
||||||
highPart(Unsigned n, std::true_type)
|
highPart(Unsigned n, std::true_type)
|
||||||
{
|
{
|
||||||
return static_cast<
|
return static_cast<
|
||||||
boost::detail::winapi::DWORD_>(
|
boost::winapi::DWORD_>(
|
||||||
(n>>32)&0xffffffff);
|
(n>>32)&0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Unsigned>
|
template<class Unsigned>
|
||||||
inline
|
inline
|
||||||
boost::detail::winapi::DWORD_
|
boost::winapi::DWORD_
|
||||||
highPart(Unsigned, std::false_type)
|
highPart(Unsigned, std::false_type)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -307,7 +307,7 @@ highPart(Unsigned, std::false_type)
|
|||||||
|
|
||||||
template<class Unsigned>
|
template<class Unsigned>
|
||||||
inline
|
inline
|
||||||
boost::detail::winapi::DWORD_
|
boost::winapi::DWORD_
|
||||||
highPart(Unsigned n)
|
highPart(Unsigned n)
|
||||||
{
|
{
|
||||||
return highPart(n, std::integral_constant<
|
return highPart(n, std::integral_constant<
|
||||||
@ -416,8 +416,8 @@ operator()()
|
|||||||
sock_, sr_, std::move(*this));
|
sock_, sr_, std::move(*this));
|
||||||
}
|
}
|
||||||
auto& r = sr_.reader_impl();
|
auto& r = sr_.reader_impl();
|
||||||
boost::detail::winapi::DWORD_ const nNumberOfBytesToWrite =
|
boost::winapi::DWORD_ const nNumberOfBytesToWrite =
|
||||||
std::min<boost::detail::winapi::DWORD_>(
|
std::min<boost::winapi::DWORD_>(
|
||||||
beast::detail::clamp(std::min<std::uint64_t>(
|
beast::detail::clamp(std::min<std::uint64_t>(
|
||||||
r.body_.last_ - r.pos_, sr_.limit())),
|
r.body_.last_ - r.pos_, sr_.limit())),
|
||||||
2147483646);
|
2147483646);
|
||||||
@ -436,12 +436,12 @@ operator()()
|
|||||||
0);
|
0);
|
||||||
auto const dwError = ::GetLastError();
|
auto const dwError = ::GetLastError();
|
||||||
if(! bSuccess && dwError !=
|
if(! bSuccess && dwError !=
|
||||||
boost::detail::winapi::ERROR_IO_PENDING_)
|
boost::winapi::ERROR_IO_PENDING_)
|
||||||
{
|
{
|
||||||
// VFALCO This needs review, is 0 the right number?
|
// VFALCO This needs review, is 0 the right number?
|
||||||
// completed immediately (with error?)
|
// completed immediately (with error?)
|
||||||
overlapped.complete(error_code{static_cast<int>(
|
overlapped.complete(error_code{static_cast<int>(
|
||||||
boost::detail::winapi::GetLastError()),
|
boost::winapi::GetLastError()),
|
||||||
system_category()}, 0);
|
system_category()}, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -513,8 +513,8 @@ write_some(
|
|||||||
r.body_.file_.seek(r.pos_, ec);
|
r.body_.file_.seek(r.pos_, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return 0;
|
return 0;
|
||||||
boost::detail::winapi::DWORD_ const nNumberOfBytesToWrite =
|
boost::winapi::DWORD_ const nNumberOfBytesToWrite =
|
||||||
std::min<boost::detail::winapi::DWORD_>(
|
std::min<boost::winapi::DWORD_>(
|
||||||
beast::detail::clamp(std::min<std::uint64_t>(
|
beast::detail::clamp(std::min<std::uint64_t>(
|
||||||
r.body_.last_ - r.pos_, sr.limit())),
|
r.body_.last_ - r.pos_, sr.limit())),
|
||||||
2147483646);
|
2147483646);
|
||||||
@ -529,7 +529,7 @@ write_some(
|
|||||||
if(! bSuccess)
|
if(! bSuccess)
|
||||||
{
|
{
|
||||||
ec.assign(static_cast<int>(
|
ec.assign(static_cast<int>(
|
||||||
boost::detail::winapi::GetLastError()),
|
boost::winapi::GetLastError()),
|
||||||
system_category());
|
system_category());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef BOOST_WINDOWS
|
#ifdef BOOST_WINDOWS
|
||||||
#include <boost/detail/winapi/basic_types.hpp>
|
#include <boost/winapi/basic_types.hpp>
|
||||||
#include <boost/detail/winapi/debugapi.hpp>
|
#include <boost/winapi/debugapi.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -45,14 +45,14 @@ class dstream_buf
|
|||||||
void write(char const* s)
|
void write(char const* s)
|
||||||
{
|
{
|
||||||
if(dbg_)
|
if(dbg_)
|
||||||
boost::detail::winapi::OutputDebugStringA(s);
|
boost::winapi::OutputDebugStringA(s);
|
||||||
os_ << s;
|
os_ << s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(wchar_t const* s)
|
void write(wchar_t const* s)
|
||||||
{
|
{
|
||||||
if(dbg_)
|
if(dbg_)
|
||||||
boost::detail::winapi::OutputDebugStringW(s);
|
boost::winapi::OutputDebugStringW(s);
|
||||||
os_ << s;
|
os_ << s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
dstream_buf(ostream& os)
|
dstream_buf(ostream& os)
|
||||||
: os_(os)
|
: os_(os)
|
||||||
, dbg_(boost::detail::winapi::IsDebuggerPresent() != 0)
|
, dbg_(boost::winapi::IsDebuggerPresent() != 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user