file did not throw exception properly when file was trunkated and read

This commit is contained in:
Arvid Norberg 2007-03-30 19:56:53 +00:00
parent e6a4733392
commit 5c9b9aefb3
1 changed files with 2 additions and 1 deletions

View File

@ -204,6 +204,7 @@ namespace libtorrent
size_type read(char* buf, size_type num_bytes)
{
assert(num_bytes > 0);
assert(m_open_mode & mode_in);
assert(m_fd != -1);
@ -212,7 +213,7 @@ namespace libtorrent
#else
size_type ret = ::read(m_fd, buf, num_bytes);
#endif
if (ret == -1)
if (ret == -1 || ret == 0)
{
std::stringstream msg;
msg << "read failed: " << strerror(errno);