From d3b5cf82d823ce43c917c5b25481ddca123e976e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 21 Nov 2019 06:17:28 -0500 Subject: [PATCH] Small adjustments --- native/jni/utils/include/stream.h | 4 ++-- native/jni/utils/stream.cpp | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/native/jni/utils/include/stream.h b/native/jni/utils/include/stream.h index b296d72ab..eaed8a144 100644 --- a/native/jni/utils/include/stream.h +++ b/native/jni/utils/include/stream.h @@ -4,7 +4,7 @@ #include #include -#include +// #include 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; }; diff --git a/native/jni/utils/stream.cpp b/native/jni/utils/stream.cpp index 1aa7d87fd..607b4d026 100644 --- a/native/jni/utils/stream.cpp +++ b/native/jni/utils/stream.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -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);