1 // Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ 6 #define CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ 7 #pragma once 8 9 #include <sstream> 10 11 #include "base/threading/platform_thread.h" 12 #include "include/cef_zip_reader.h" 13 #include "third_party/zlib/contrib/minizip/unzip.h" 14 15 // Implementation of CefZipReader 16 class CefZipReaderImpl : public CefZipReader { 17 public: 18 CefZipReaderImpl(); 19 ~CefZipReaderImpl() override; 20 21 // Initialize the reader context. 22 bool Initialize(CefRefPtr<CefStreamReader> stream); 23 24 bool MoveToFirstFile() override; 25 bool MoveToNextFile() override; 26 bool MoveToFile(const CefString& fileName, bool caseSensitive) override; 27 bool Close() override; 28 CefString GetFileName() override; 29 int64 GetFileSize() override; 30 CefTime GetFileLastModified() override; 31 bool OpenFile(const CefString& password) override; 32 bool CloseFile() override; 33 int ReadFile(void* buffer, size_t bufferSize) override; 34 int64 Tell() override; 35 bool Eof() override; 36 37 bool GetFileInfo(); 38 39 // Verify that the reader exists and is being accessed from the correct 40 // thread. 41 bool VerifyContext(); 42 43 protected: 44 base::PlatformThreadId supported_thread_id_; 45 unzFile reader_; 46 bool has_fileopen_; 47 bool has_fileinfo_; 48 CefString filename_; 49 int64 filesize_; 50 time_t filemodified_; 51 52 IMPLEMENT_REFCOUNTING(CefZipReaderImpl); 53 }; 54 55 #endif // CEF_LIBCEF_BROWSER_ZIP_READER_IMPL_H_ 56