input/InputStream: migrate from class Error to C++ exceptions
This commit is contained in:
@@ -22,16 +22,17 @@
|
||||
#include "thread/Cond.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
InputStream::~InputStream()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::Check(gcc_unused Error &error)
|
||||
void
|
||||
InputStream::Check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -86,25 +87,24 @@ InputStream::CheapSeeking() const
|
||||
return IsSeekable() && !ExpensiveSeeking(uri.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::Seek(gcc_unused offset_type new_offset,
|
||||
gcc_unused Error &error)
|
||||
void
|
||||
InputStream::Seek(gcc_unused offset_type new_offset)
|
||||
{
|
||||
return false;
|
||||
throw std::runtime_error("Seeking is not implemented");
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::LockSeek(offset_type _offset, Error &error)
|
||||
void
|
||||
InputStream::LockSeek(offset_type _offset)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
return Seek(_offset, error);
|
||||
Seek(_offset);
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::LockSkip(offset_type _offset, Error &error)
|
||||
void
|
||||
InputStream::LockSkip(offset_type _offset)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
return Skip(_offset, error);
|
||||
Skip(_offset);
|
||||
}
|
||||
|
||||
Tag *
|
||||
@@ -127,7 +127,7 @@ InputStream::IsAvailable()
|
||||
}
|
||||
|
||||
size_t
|
||||
InputStream::LockRead(void *ptr, size_t _size, Error &error)
|
||||
InputStream::LockRead(void *ptr, size_t _size)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
@@ -136,28 +136,27 @@ InputStream::LockRead(void *ptr, size_t _size, Error &error)
|
||||
assert(_size > 0);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
return Read(ptr, _size, error);
|
||||
return Read(ptr, _size);
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::ReadFull(void *_ptr, size_t _size, Error &error)
|
||||
void
|
||||
InputStream::ReadFull(void *_ptr, size_t _size)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)_ptr;
|
||||
|
||||
size_t nbytes_total = 0;
|
||||
while (_size > 0) {
|
||||
size_t nbytes = Read(ptr + nbytes_total, _size, error);
|
||||
size_t nbytes = Read(ptr + nbytes_total, _size);
|
||||
if (nbytes == 0)
|
||||
return false;
|
||||
throw std::runtime_error("Unexpected end of file");
|
||||
|
||||
nbytes_total += nbytes;
|
||||
_size -= nbytes;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::LockReadFull(void *ptr, size_t _size, Error &error)
|
||||
void
|
||||
InputStream::LockReadFull(void *ptr, size_t _size)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
@@ -166,7 +165,7 @@ InputStream::LockReadFull(void *ptr, size_t _size, Error &error)
|
||||
assert(_size > 0);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
return ReadFull(ptr, _size, error);
|
||||
ReadFull(ptr, _size);
|
||||
}
|
||||
|
||||
bool
|
||||
|
Reference in New Issue
Block a user