InputStream: "protect" attributes

This commit is contained in:
Max Kellermann
2014-05-11 18:34:09 +02:00
parent e138e2c880
commit 0b4fa41aff
14 changed files with 53 additions and 37 deletions

View File

@@ -93,7 +93,7 @@ private:
* buffer contain more data for the next read operation?
*/
bool ReadingFromBuffer() const {
return tail > 0 && offset < input->offset;
return tail > 0 && offset < input->GetOffset();
}
/**
@@ -116,7 +116,7 @@ private:
SetReady();
}
offset = src->offset;
offset = src->GetOffset();
}
};
@@ -127,7 +127,7 @@ RewindInputStream::Read(void *ptr, size_t read_size, Error &error)
/* buffered read */
assert(head == (size_t)offset);
assert(tail == (size_t)input->offset);
assert(tail == (size_t)input->GetOffset());
if (read_size > tail - head)
read_size = tail - head;
@@ -142,7 +142,7 @@ RewindInputStream::Read(void *ptr, size_t read_size, Error &error)
size_t nbytes = input->Read(ptr, read_size, error);
if (input->offset > (InputPlugin::offset_type)sizeof(buffer))
if (input->GetOffset() > (offset_type)sizeof(buffer))
/* disable buffering */
tail = 0;
else if (tail == (size_t)offset) {
@@ -151,7 +151,7 @@ RewindInputStream::Read(void *ptr, size_t read_size, Error &error)
memcpy(buffer + tail, ptr, nbytes);
tail += nbytes;
assert(tail == (size_t)input->offset);
assert(tail == (size_t)input->GetOffset());
}
CopyAttributes();
@@ -172,7 +172,7 @@ RewindInputStream::Seek(InputPlugin::offset_type new_offset, int whence,
assert(!ReadingFromBuffer() ||
head == (size_t)offset);
assert(tail == (size_t)input->offset);
assert(tail == (size_t)input->GetOffset());
head = (size_t)new_offset;
offset = new_offset;
@@ -194,7 +194,7 @@ InputStream *
input_rewind_open(InputStream *is)
{
assert(is != nullptr);
assert(is->offset == 0);
assert(is->GetOffset() == 0);
if (is->IsReady() && is->IsSeekable())
/* seekable resources don't need this plugin */