1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // The contents of this file must follow a specific format in order to 33 // support the CEF translator tool. See the translator.README.txt file in the 34 // tools directory for more information. 35 // 36 37 #ifndef CEF_INCLUDE_CEF_ZIP_READER_H_ 38 #define CEF_INCLUDE_CEF_ZIP_READER_H_ 39 40 #include "include/cef_base.h" 41 #include "include/cef_stream.h" 42 43 /// 44 // Class that supports the reading of zip archives via the zlib unzip API. 45 // The methods of this class should only be called on the thread that creates 46 // the object. 47 /// 48 /*--cef(source=library)--*/ 49 class CefZipReader : public virtual CefBaseRefCounted { 50 public: 51 /// 52 // Create a new CefZipReader object. The returned object's methods can only 53 // be called from the thread that created the object. 54 /// 55 /*--cef()--*/ 56 static CefRefPtr<CefZipReader> Create(CefRefPtr<CefStreamReader> stream); 57 58 /// 59 // Moves the cursor to the first file in the archive. Returns true if the 60 // cursor position was set successfully. 61 /// 62 /*--cef()--*/ 63 virtual bool MoveToFirstFile() = 0; 64 65 /// 66 // Moves the cursor to the next file in the archive. Returns true if the 67 // cursor position was set successfully. 68 /// 69 /*--cef()--*/ 70 virtual bool MoveToNextFile() = 0; 71 72 /// 73 // Moves the cursor to the specified file in the archive. If |caseSensitive| 74 // is true then the search will be case sensitive. Returns true if the cursor 75 // position was set successfully. 76 /// 77 /*--cef()--*/ 78 virtual bool MoveToFile(const CefString& fileName, bool caseSensitive) = 0; 79 80 /// 81 // Closes the archive. This should be called directly to ensure that cleanup 82 // occurs on the correct thread. 83 /// 84 /*--cef()--*/ 85 virtual bool Close() = 0; 86 87 // The below methods act on the file at the current cursor position. 88 89 /// 90 // Returns the name of the file. 91 /// 92 /*--cef()--*/ 93 virtual CefString GetFileName() = 0; 94 95 /// 96 // Returns the uncompressed size of the file. 97 /// 98 /*--cef()--*/ 99 virtual int64 GetFileSize() = 0; 100 101 /// 102 // Returns the last modified timestamp for the file. 103 /// 104 /*--cef()--*/ 105 virtual CefTime GetFileLastModified() = 0; 106 107 /// 108 // Opens the file for reading of uncompressed data. A read password may 109 // optionally be specified. 110 /// 111 /*--cef(optional_param=password)--*/ 112 virtual bool OpenFile(const CefString& password) = 0; 113 114 /// 115 // Closes the file. 116 /// 117 /*--cef()--*/ 118 virtual bool CloseFile() = 0; 119 120 /// 121 // Read uncompressed file contents into the specified buffer. Returns < 0 if 122 // an error occurred, 0 if at the end of file, or the number of bytes read. 123 /// 124 /*--cef()--*/ 125 virtual int ReadFile(void* buffer, size_t bufferSize) = 0; 126 127 /// 128 // Returns the current offset in the uncompressed file contents. 129 /// 130 /*--cef()--*/ 131 virtual int64 Tell() = 0; 132 133 /// 134 // Returns true if at end of the file contents. 135 /// 136 /*--cef()--*/ 137 virtual bool Eof() = 0; 138 }; 139 140 #endif // CEF_INCLUDE_CEF_ZIP_READER_H_ 141