InputStream: add constant UNKNOWN_SIZE

This commit is contained in:
Max Kellermann 2014-08-19 11:56:12 +02:00
parent f66a72c66b
commit 4265e71d6f
2 changed files with 6 additions and 4 deletions

View File

@ -76,8 +76,10 @@ protected:
*/ */
bool seekable; bool seekable;
static constexpr offset_type UNKNOWN_SIZE = -1;
/** /**
* the size of the resource, or -1 if unknown * the size of the resource, or #UNKNOWN_SIZE if unknown
*/ */
offset_type size; offset_type size;
@ -97,7 +99,7 @@ public:
:uri(_uri), :uri(_uri),
mutex(_mutex), cond(_cond), mutex(_mutex), cond(_cond),
ready(false), seekable(false), ready(false), seekable(false),
size(-1), offset(0) { size(UNKNOWN_SIZE), offset(0) {
assert(_uri != nullptr); assert(_uri != nullptr);
} }
@ -221,7 +223,7 @@ public:
bool KnownSize() const { bool KnownSize() const {
assert(ready); assert(ready);
return size >= 0; return size != UNKNOWN_SIZE;
} }
gcc_pure gcc_pure

View File

@ -42,7 +42,7 @@ ProxyInputStream::CopyAttributes()
size = input.KnownSize() size = input.KnownSize()
? input.GetSize() ? input.GetSize()
: -1; : UNKNOWN_SIZE;
seekable = input.IsSeekable(); seekable = input.IsSeekable();
SetReady(); SetReady();