2011-01-10 02:31:12 +01:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
2010-10-24 18:41:21 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_ZIP_READER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_ZIP_READER_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <sstream>
|
2010-10-24 18:41:21 +02:00
|
|
|
|
2011-12-23 18:36:30 +01:00
|
|
|
#include "include/cef_zip_reader.h"
|
2011-01-07 22:34:20 +01:00
|
|
|
#include "base/threading/platform_thread.h"
|
2010-10-24 18:41:21 +02:00
|
|
|
#include "third_party/zlib/contrib/minizip/unzip.h"
|
|
|
|
|
|
|
|
// Implementation of CefZipReader
|
2012-01-10 00:46:23 +01:00
|
|
|
class CefZipReaderImpl : public CefZipReader {
|
|
|
|
public:
|
2010-10-24 18:41:21 +02:00
|
|
|
CefZipReaderImpl();
|
|
|
|
~CefZipReaderImpl();
|
|
|
|
|
|
|
|
// Initialize the reader context.
|
|
|
|
bool Initialize(CefRefPtr<CefStreamReader> stream);
|
|
|
|
|
|
|
|
virtual bool MoveToFirstFile();
|
|
|
|
virtual bool MoveToNextFile();
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual bool MoveToFile(const CefString& fileName, bool caseSensitive);
|
2010-10-24 18:41:21 +02:00
|
|
|
virtual bool Close();
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual CefString GetFileName();
|
2012-01-10 00:46:23 +01:00
|
|
|
virtual int64 GetFileSize();
|
2010-10-24 18:41:21 +02:00
|
|
|
virtual time_t GetFileLastModified();
|
2010-11-22 18:49:46 +01:00
|
|
|
virtual bool OpenFile(const CefString& password);
|
2010-10-24 18:41:21 +02:00
|
|
|
virtual bool CloseFile();
|
|
|
|
virtual int ReadFile(void* buffer, size_t bufferSize);
|
2012-01-10 00:46:23 +01:00
|
|
|
virtual int64 Tell();
|
2010-10-24 18:41:21 +02:00
|
|
|
virtual bool Eof();
|
|
|
|
|
|
|
|
bool GetFileInfo();
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2010-10-24 18:41:21 +02:00
|
|
|
// Verify that the reader exists and is being accessed from the correct
|
|
|
|
// thread.
|
|
|
|
bool VerifyContext();
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
protected:
|
2011-01-07 22:34:20 +01:00
|
|
|
base::PlatformThreadId supported_thread_id_;
|
2010-10-24 18:41:21 +02:00
|
|
|
unzFile reader_;
|
|
|
|
bool has_fileopen_;
|
|
|
|
bool has_fileinfo_;
|
2010-11-22 18:49:46 +01:00
|
|
|
CefString filename_;
|
2012-01-10 00:46:23 +01:00
|
|
|
int64 filesize_;
|
2010-10-24 18:41:21 +02:00
|
|
|
time_t filemodified_;
|
2011-05-20 16:42:25 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefZipReaderImpl);
|
2010-10-24 18:41:21 +02:00
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_ZIP_READER_IMPL_H_
|