diff options
Diffstat (limited to 'libs/androidfw/ZipUtils.cpp')
-rw-r--r-- | libs/androidfw/ZipUtils.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp index 58fc5bbbab5e..568e3b63d67f 100644 --- a/libs/androidfw/ZipUtils.cpp +++ b/libs/androidfw/ZipUtils.cpp @@ -40,7 +40,7 @@ class FileReader : public zip_archive::Reader { explicit FileReader(FILE* fp) : Reader(), mFp(fp), mCurrentOffset(0) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { // Data is usually requested sequentially, so this helps avoid pointless // fseeks every time we perform a read. There's an impedence mismatch // here because the original API was designed around pread and pwrite. @@ -71,7 +71,7 @@ class FdReader : public zip_archive::Reader { explicit FdReader(int fd) : mFd(fd) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { return android::base::ReadFullyAtOffset(mFd, buf, len, offset); } @@ -81,27 +81,22 @@ class FdReader : public zip_archive::Reader { class BufferReader : public zip_archive::Reader { public: - BufferReader(incfs::map_ptr<void> input, size_t inputSize) : Reader(), - mInput(input.convert<uint8_t>()), + BufferReader(const void* input, size_t inputSize) : Reader(), + mInput(reinterpret_cast<const uint8_t*>(input)), mInputSize(inputSize) { } - bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const override { + bool ReadAtOffset(uint8_t* buf, size_t len, off64_t offset) const { if (mInputSize < len || offset > mInputSize - len) { return false; } - const incfs::map_ptr<uint8_t> pos = mInput.offset(offset); - if (!pos.verify(len)) { - return false; - } - - memcpy(buf, pos.unsafe_ptr(), len); + memcpy(buf, mInput + offset, len); return true; } private: - const incfs::map_ptr<uint8_t> mInput; + const uint8_t* mInput; const size_t mInputSize; }; @@ -143,7 +138,7 @@ class BufferWriter : public zip_archive::Writer { return (zip_archive::Inflate(reader, compressedLen, uncompressedLen, &writer, nullptr) == 0); } -/*static*/ bool ZipUtils::inflateToBuffer(incfs::map_ptr<void> in, void* buf, +/*static*/ bool ZipUtils::inflateToBuffer(const void* in, void* buf, long uncompressedLen, long compressedLen) { BufferReader reader(in, compressedLen); |