input/InputStream: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-09-09 18:47:42 +02:00
parent 597e59f10d
commit 8c744efd56
64 changed files with 440 additions and 473 deletions

View File

@@ -28,15 +28,16 @@
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "tag/TagId3.hxx"
#include "util/Error.hxx"
#include <string.h>
#include <stdlib.h>
#ifdef ENABLE_ID3TAG
#include <id3tag.h>
#endif
#include <stdexcept>
#include <string.h>
#include <stdlib.h>
bool
DsdId::Equals(const char *s) const
{
@@ -53,8 +54,13 @@ bool
dsdlib_skip_to(Decoder *decoder, InputStream &is,
offset_type offset)
{
if (is.IsSeekable())
return is.LockSeek(offset, IgnoreError());
if (is.IsSeekable()) {
try {
is.LockSeek(offset);
} catch (const std::runtime_error &) {
return false;
}
}
if (is.GetOffset() > offset)
return false;
@@ -72,8 +78,13 @@ dsdlib_skip(Decoder *decoder, InputStream &is,
if (delta == 0)
return true;
if (is.IsSeekable())
return is.LockSeek(is.GetOffset() + delta, IgnoreError());
if (is.IsSeekable()) {
try {
is.LockSeek(is.GetOffset() + delta);
} catch (const std::runtime_error &) {
return false;
}
}
if (delta > 1024 * 1024)
/* don't skip more than one megabyte; it would be too