#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_BLOBLOOKINSTREAM_H #define NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_BLOBLOOKINSTREAM_H #include "Nuclex/Storage/Config.h" #include "Nuclex/Storage/Blob.h" #include #include #include "lzma/7z.h" namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip { // ------------------------------------------------------------------------------------------- // /// Implements 7-Zip's ILookInStream interface on a Blob class BlobLookInStream : public ILookInStream { /// Initializes a new Blob-based ILookInStream /// Blob the ILookInStream instance will access public: BlobLookInStream(const std::shared_ptr &blob); /// Reads data from the blob without moving the file pointer /// The ILookInStream instance /// /// Receives a callee-managed buffer containing the data that has been read /// /// Number of bytes that will be skipped private: static SRes look(void *self, const void **buffer, size_t *length); /// Skips over a number of bytes in the blob /// The ILookInStream instance /// Number of bytes that will be skipped private: static SRes skip(void *self, size_t offset); /// Reads a number of bytes from the blob /// The ILookInStream instance /// Buffer into which the data will be read /// Number of bytes to read and actually read private: static SRes read(void *self, void *buffer, size_t *length); /// Moves to a different position within the blob /// The ILookInStream instance /// Position to which the file pointer will be moved /// Position relative to which to seek private: static SRes seek(void *self, Int64 *position, ESzSeek origin); private: std::shared_ptr blob; /// Location of the file pointer private: std::uint64_t location; /// Length of the blob private: std::uint64_t length; /// Stupid buffer because the ILookToRead interface does crazy stuff private: std::vector buffer; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::FileSystem::SevenZip #endif // NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_BLOBLOOKINSTREAM_H