Commit d3b5cf82 authored by topjohnwu's avatar topjohnwu

Small adjustments

parent d26d804c
......@@ -4,7 +4,7 @@
#include <stdio.h>
#include <memory>
#include <utils.h>
// #include <utils.h>
class stream;
......@@ -49,7 +49,7 @@ class seekable_stream : public stream {
protected:
size_t _pos = 0;
off_t new_pos(off_t off, int whence);
off_t seek_pos(off_t off, int whence);
virtual size_t end_pos() = 0;
};
......
#include <utils.h>
#include <logging.h>
#include <stream.h>
......@@ -68,22 +69,17 @@ void filter_stream::set_base(FILE *f) {
fp = f;
}
off_t seekable_stream::new_pos(off_t off, int whence) {
off_t new_pos;
off_t seekable_stream::seek_pos(off_t off, int whence) {
switch (whence) {
case SEEK_CUR:
new_pos = _pos + off;
break;
return _pos + off;
case SEEK_END:
new_pos = end_pos() + off;
break;
return end_pos() + off;
case SEEK_SET:
new_pos = off;
break;
return off;
default:
return -1;
}
return new_pos;
}
byte_stream::byte_stream(uint8_t *&buf, size_t &len) : _buf(buf), _len(len) {
......@@ -106,7 +102,7 @@ int byte_stream::write(const void *buf, size_t len) {
}
off_t byte_stream::seek(off_t off, int whence) {
off_t np = new_pos(off, whence);
off_t np = seek_pos(off, whence);
if (np < 0)
return -1;
resize(np, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment