#include "third_party/zlib/google/zip_reader.h"
#include <algorithm>
#include <string_view>
#include <utility>
#include "base/check.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "third_party/zlib/google/redact.h"
#include "third_party/zlib/google/zip_internal.h"
#if defined(USE_SYSTEM_MINIZIP)
#include <minizip/unzip.h>
#else
#include "third_party/zlib/contrib/minizip/unzip.h"
#if defined(OS_WIN)
#include "third_party/zlib/contrib/minizip/iowin32.h"
#endif
#endif
#if defined(OS_POSIX)
#include <sys/stat.h>
#endif
namespace zip {
namespace {
enum UnzipError : int;
std::ostream& operator<<(std::ostream& out, UnzipError error) { … }
bool IsValidFileNameCharacterOnWindows(char16_t c) { … }
class StringWriterDelegate : public WriterDelegate { … };
#if defined(OS_POSIX)
void SetPosixFilePermissions(int fd, int mode) { … }
#endif
}
ZipReader::ZipReader() { … }
ZipReader::~ZipReader() { … }
bool ZipReader::Open(const base::FilePath& zip_path) { … }
bool ZipReader::OpenFromPlatformFile(base::PlatformFile zip_fd) { … }
bool ZipReader::OpenFromString(const std::string& data) { … }
void ZipReader::Close() { … }
const ZipReader::Entry* ZipReader::Next() { … }
bool ZipReader::OpenEntry() { … }
void ZipReader::Normalize(std::u16string_view in) { … }
void ZipReader::ReportProgress(ListenerCallback listener_callback,
uint64_t bytes) const { … }
bool ZipReader::ExtractCurrentEntry(WriterDelegate* delegate,
ListenerCallback listener_callback,
uint64_t num_bytes_to_extract) const { … }
bool ZipReader::ExtractCurrentEntry(WriterDelegate* delegate,
uint64_t num_bytes_to_extract) const { … }
bool ZipReader::ExtractCurrentEntryWithListener(
WriterDelegate* delegate,
ListenerCallback listener_callback) const { … }
void ZipReader::ExtractCurrentEntryToFilePathAsync(
const base::FilePath& output_file_path,
SuccessCallback success_callback,
FailureCallback failure_callback,
ProgressCallback progress_callback) { … }
bool ZipReader::ExtractCurrentEntryToString(uint64_t max_read_bytes,
std::string* output) const { … }
bool ZipReader::OpenInternal() { … }
void ZipReader::Reset() { … }
void ZipReader::ExtractChunk(base::File output_file,
SuccessCallback success_callback,
FailureCallback failure_callback,
ProgressCallback progress_callback,
int64_t offset) { … }
FileWriterDelegate::FileWriterDelegate(base::File* file) : … { … }
FileWriterDelegate::FileWriterDelegate(base::File owned_file)
: … { … }
FileWriterDelegate::~FileWriterDelegate() { … }
bool FileWriterDelegate::PrepareOutput() { … }
bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { … }
void FileWriterDelegate::SetTimeModified(const base::Time& time) { … }
void FileWriterDelegate::SetPosixFilePermissions(int mode) { … }
void FileWriterDelegate::OnError() { … }
FilePathWriterDelegate::FilePathWriterDelegate(base::FilePath output_file_path)
: … { … }
FilePathWriterDelegate::~FilePathWriterDelegate() { … }
bool FilePathWriterDelegate::PrepareOutput() { … }
void FilePathWriterDelegate::OnError() { … }
}