#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_SEVENZIPPEDFILE_H #define NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPPEDFILE_H #include "Nuclex/Storage/Config.h" #include "../Generic/GenericArchivedFile.h" namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip { // ------------------------------------------------------------------------------------------- // class SevenZipArchiveContainer; class SevenZipReader; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::FileSystem::Zip namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip { // ------------------------------------------------------------------------------------------- // /// File stored in a 7-zip archive class SevenZippedFile : public GenericArchivedFile { #pragma region struct MetaData /// Data about the compressed file public: struct MetaData { /// Index of the file within the archive public: std::size_t Index; /// Full path of the file in the native system public: std::string NativePath; /// Name of the file public: std::string Filename; /// Length of the file when it is uncompressed public: std::uint64_t UncompressedSize; /// Time at which the file has been last modified public: std::time_t LastModificationTime; /// Index of the solid block containing the file public: std::size_t SolidBlockIndex; /// Offset of the file within the uncompressed solid block public: std::uint64_t SolidBlockOffset; }; #pragma endregion // struct MetaData /// Initializes a new file stored in a 7-zip archive /// Cached reader for the file's contents /// Data describing the compressed file public: SevenZippedFile( const std::shared_ptr &sevenZipReader, const MetaData &metaData ); /// Frees all resources owned by the instance public: virtual ~SevenZippedFile(); /// Determines the size of the file /// The size of the file in bytes public: std::uint64_t GetSize() const { return this->metaData.UncompressedSize; } /// Returns the name of the file /// The file's name public: const std::string &GetName() const { return this->metaData.Filename; } /// Returns the path the file is stored at in the native format /// The file's absolute path in the native OS format public: const std::string &GetNativePath() const { return this->metaData.NativePath; } /// Retrieves the time at which the file has been last modified /// The since since the last modification of the file took place public: std::time_t GetLastModificationTime() const { return this->metaData.LastModificationTime; } /// Reads raw data from the file /// Absolute file position data will be read from /// Buffer into which data will be read /// Number of bytes that will be read public: void ReadAt( std::uint64_t location, void *buffer, std::size_t count ) const; /// Decompresses data from the 7-zip archive private: std::shared_ptr sevenZipReader; /// Describing informations about the compressed file private: MetaData metaData; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::FileSystem::SevenZip #endif // NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPPEDFILE_H