10#ifndef BITOUTPUTARCHIVE_HPP
11#define BITOUTPUTARCHIVE_HPP
16#include "bitabstractarchivecreator.hpp"
17#include "bititemsvector.hpp"
18#include "bitexception.hpp"
19#include "bitpropvariant.hpp"
22struct ISequentialInStream;
174 const tstring& filter = BIT7Z_STRING(
"*" ),
175 bool recursive =
true );
187 const tstring& filter = BIT7Z_STRING(
"*" ),
189 bool recursive =
true );
247 virtual auto itemStream( InputIndex index, ISequentialInStream** inStream ) const -> HRESULT;
249 virtual auto hasNewData( uint32_t index ) const noexcept ->
bool;
251 virtual auto hasNewProperties( uint32_t index ) const noexcept ->
bool;
253 auto itemInputIndex( uint32_t newIndex ) const noexcept -> InputIndex;
257 auto outputItemStream( uint32_t index, ISequentialInStream** inStream ) const -> HRESULT;
259 auto indexInArchive( uint32_t index ) const noexcept -> uint32_t;
262 return mInputArchive.get();
266 mInputArchive = std::move( inputArchive );
269 inline auto inputArchiveItemsCount() const -> uint32_t {
270 return mInputArchiveItemsCount;
273 inline void setDeletedIndex( uint32_t index ) {
274 mDeletedItems.insert( index );
277 inline auto isDeletedIndex( uint32_t index )
const ->
bool {
278 return mDeletedItems.find( index ) != mDeletedItems.cend();
281 inline auto hasDeletedIndexes() const ->
bool {
282 return !mDeletedItems.empty();
285 inline auto hasNewItems() const ->
bool {
286 return mNewItemsVector.
size() > 0;
289 friend class UpdateCallback;
292 const BitAbstractArchiveCreator& mArchiveCreator;
294 unique_ptr< BitInputArchive > mInputArchive;
295 uint32_t mInputArchiveItemsCount;
297 BitItemsVector mNewItemsVector;
298 DeletedItems mDeletedItems;
300 mutable FailedFiles mFailedFiles;
315 auto initOutArchive() const -> CMyComPtr< IOutArchive >;
317 auto initOutFileStream( const fs::path& outArchive,
bool updatingArchive ) const -> CMyComPtr< IOutStream >;
319 BitOutputArchive( const BitAbstractArchiveCreator&
creator, const fs::path& inArc );
321 void compressToFile( const fs::path& outFile, UpdateCallback* updateCallback );
323 void compressOut( IOutArchive* outArc, IOutStream* outStream, UpdateCallback* updateCallback );
325 void setArchiveProperties( IOutArchive* outArchive ) const;
327 void updateInputIndices();
Abstract class representing a generic archive creator.
Definition bitabstractarchivecreator.hpp:44
Abstract class representing a generic archive handler.
Definition bitabstractarchivehandler.hpp:74
auto size() const -> std::size_t
The BitOutputArchive class, given a creator object, allows creating new archives.
Definition bitoutputarchive.hpp:60
void addFiles(const tstring &inDir, const tstring &filter="*", FilterPolicy policy=FilterPolicy::Include, bool recursive=true)
Adds all the files inside the given directory path that match the given wildcard filter.
void addItems(const std::map< tstring, tstring > &inPaths)
Adds all the items that can be found by indexing the keys of the given map of filesystem paths; the c...
void addFile(const std::vector< byte_t > &inBuffer, const tstring &name)
Adds the given buffer file, using the given name as a path when compressed in the output archive.
void compressTo(std::vector< byte_t > &outBuffer)
Compresses all the items added to this object to the specified buffer.
void addFiles(const tstring &inDir, const tstring &filter="*", bool recursive=true)
Adds all the files inside the given directory path that match the given wildcard filter.
void compressTo(std::ostream &outStream)
Compresses all the items added to this object to the specified buffer.
BitOutputArchive(const BitAbstractArchiveCreator &creator, const tstring &inFile)
Constructs a BitOutputArchive object, opening an (optional) input file archive.
void addFiles(const std::vector< tstring > &inFiles)
Adds all the files in the given vector of filesystem paths.
void compressTo(const tstring &outFile)
Compresses all the items added to this object to the specified archive file path.
void addFile(const tstring &inFile, const tstring &name={})
Adds the given file path, with an optional user-defined path to be used in the output archive.
void addFile(std::istream &inStream, const tstring &name)
Adds the given standard input stream, using the given name as a path when compressed in the output ar...
void addItems(const std::vector< tstring > &inPaths)
Adds all the items that can be found by indexing the given vector of filesystem paths.
BitOutputArchive(const BitAbstractArchiveCreator &creator, std::istream &inStream)
Constructs a BitOutputArchive object, reading an input file archive from the given std::istream.
auto handler() const noexcept -> const BitAbstractArchiveHandler &
auto itemsCount() const -> uint32_t
void addDirectory(const tstring &inDir)
Adds all the items inside the given directory path.
auto creator() const noexcept -> const BitAbstractArchiveCreator &
BitOutputArchive(const BitAbstractArchiveCreator &creator)
Constructs a BitOutputArchive object for a completely new archive.
BitOutputArchive(const BitAbstractArchiveCreator &creator, const std::vector< byte_t > &inBuffer)
Constructs a BitOutputArchive object, opening an input file archive from the given buffer.
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30
BitProperty
The BitProperty enum represents the archive/item properties that 7-zip can read or write.
Definition bitpropvariant.hpp:30
FilterPolicy
Enumeration representing the policy according to which the archive handler should treat the items tha...
Definition bitabstractarchivehandler.hpp:66
@ Include
Extract/compress the items that match the pattern.
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:150