#pragma region CPL License
/*
Nuclex Native Framework
Copyright (C) 2002-2013 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#pragma endregion // CPL License
#ifndef NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPREADER_H
#define NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPREADER_H
#include "Nuclex/Storage/Config.h"
#include "../../Helpers/StreamingCacheContext.h"
#include "SevenZippedFile.h"
#include "SevenZipArchive.h"
namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip {
// ------------------------------------------------------------------------------------------- //
/// Reads data from 7-Zip archives
class SevenZipReader : public Helpers::Cache {
/// Initializes a new 7-Zip compressed data reader
/// 7-Zip archive the reader will extract from
public: SevenZipReader(const std::shared_ptr &sevenZipArchive);
/// Frees all memory used by the 7-Zip reader
public: virtual ~SevenZipReader() {}
/// Reads the specified number of bytes from the file
/// Meta data about the file being accessed
/// Absolute file position the data will be read from
/// Buffer into which the data will be read
/// Number of bytes that will be read
public: void ReadAt(
const SevenZippedFile::MetaData &metaData,
std::uint64_t position, void *buffer, std::size_t count
);
/// Creates a new context storing the state of a decompressor
///
/// Index of the solid block for which a decompression context will be created
///
/// The new context
protected: virtual Context *CreateContext(const std::size_t &solidBlockIndex);
/// Creates a context using a single coder to decompress data
private: Context *SevenZipReader::createSingleCoderContext(
CSzCoderInfo &coder, std::size_t solidBlockIndex
);
private: SevenZipReader(const SevenZipReader &);
private: SevenZipReader &operator =(const SevenZipReader &);
/// 7-Zip archive that will be extracted
private: std::shared_ptr sevenZipArchive;
};
// ------------------------------------------------------------------------------------------- //
}}}} // namespace Nuclex::Storage::FileSystem::SevenZip
#endif // NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPREADER_H