#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_SEVENZIPDIRECTORYREADER_H #define NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPDIRECTORYREADER_H #include "Nuclex/Storage/Config.h" #include #include #include #include namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip { // ------------------------------------------------------------------------------------------- // class SevenZippedContainer; class SevenZippedFile; class SevenZipArchive; class SevenZipReader; struct LocalFileHeader; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::FileSystem::SevenZip namespace Nuclex { namespace Storage { // ------------------------------------------------------------------------------------------- // class Blob; // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Storage namespace Nuclex { namespace Storage { namespace FileSystem { namespace SevenZip { // ------------------------------------------------------------------------------------------ -// /// /// Reads the directory of a zip archive and creates the appropriate objects /// class SevenZipDirectoryReader { /// Smart pointer to a zipped container private: typedef std::shared_ptr SevenZippedContainerPointer; /// Smart pointer to a zipped file private: typedef std::shared_ptr SevenZippedFilePointer; /// Map of file names to zipped file informations private: typedef std::map SevenZippedContainerMap; /// Initializes a new zip directory reader /// System-specific path to the zip archive /// Zip archive of which the directory will be read public: SevenZipDirectoryReader( const std::string &nativeArchivePath, const std::shared_ptr &archive ); /// Frees all resources owned by the instance public: ~SevenZipDirectoryReader(); /// Reads the zip archive's directory public: void ReadDirectory(); /// Returns the root directory level container of the zip archive /// The container forthe zip archive's root directory level public: const std::shared_ptr &GetRootContainer() const; /// Creates wrappers for the files and folder in the 7-Zip archive private: void readArchiveStructure(); /// Adds an archived file to the hierarchy /// Index of the file in the archive /// Full path of the file or directory /// Whether the file is a directory private: void processArchivedFile( std::size_t index, const std::string &path, bool isDirectory ); /// Retrieves or creates a new container for the specified path /// Directory for which the container will be returned /// The container for the specified directory private: const std::shared_ptr &getOrCreateContainerForDirectory( const std::string &directory ); /// Determines the parent directory of the specified directory /// Directory whose parent directory will be determined /// The parent directory of the specified directory private: static std::string getParentDirectory(const std::string &directory); /// Determines the name of the directory in the specified path /// /// Path from which the name of the deepest directory will be returned /// /// The name of the deepest directory in the specified path private: static std::string getDirectoryName(const std::string &path); private: SevenZipDirectoryReader(const SevenZipDirectoryReader &); private: SevenZipDirectoryReader &operator =(const SevenZipDirectoryReader &); /// Zip archive path in the format native to the operating system private: std::string nativeArchivePath; /// Cache that will be used to extract deflate-compressed files private: std::shared_ptr zipReader; /// 7-Zip archive that will be accessed by the file wrappers private: std::shared_ptr sevenZipArchive; /// Containers by their paths private: SevenZippedContainerMap containers; }; // ------------------------------------------------------------------------------------------- // }}}} // namespace Nuclex::Storage::FileSystem::SevenZip #endif // NUCLEX_STORAGE_FILESYSTEM_SEVENZIP_SEVENZIPDIRECTORYREADER_H