forked from boostorg/beast
Use fwrite return value in file_body
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
1.0.0-b33
|
1.0.0-b33
|
||||||
|
|
||||||
* Require Visual Studio 2015 Update 3 or later
|
* Require Visual Studio 2015 Update 3 or later
|
||||||
|
* Use fwrite return value in file_body
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <beast/core/error.hpp>
|
#include <beast/core/error.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <beast/http/message.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
|
#include <boost/assert.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -74,15 +75,17 @@ struct file_body
|
|||||||
size_ - offset_);
|
size_ - offset_);
|
||||||
else
|
else
|
||||||
buf_len_ = sizeof(buf_);
|
buf_len_ = sizeof(buf_);
|
||||||
auto const nread = fread(buf_, 1, sizeof(buf_), file_);
|
auto const nread = fread(
|
||||||
|
buf_, 1, sizeof(buf_), file_);
|
||||||
if(ferror(file_))
|
if(ferror(file_))
|
||||||
{
|
{
|
||||||
ec = error_code(errno,
|
ec = error_code(errno,
|
||||||
system_category());
|
system_category());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
offset_ += buf_len_;
|
BOOST_ASSERT(nread != 0);
|
||||||
wf(boost::asio::buffer(buf_, buf_len_));
|
offset_ += nread;
|
||||||
|
wf(boost::asio::buffer(buf_, nread));
|
||||||
return offset_ >= size_;
|
return offset_ >= size_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user