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;
97 const buffer_t& inBuffer,
190 const tstring& filter = BIT7Z_STRING(
"*" ),
192 bool recursive =
true );
228 const tstring& filter = BIT7Z_STRING(
"*" ),
230 bool recursive =
true );
281 virtual auto itemStream( InputIndex index, ISequentialInStream** inStream ) const -> HRESULT;
283 virtual auto hasNewData( uint32_t index ) const noexcept ->
bool;
285 virtual auto hasNewProperties( uint32_t index ) const noexcept ->
bool;
287 auto itemInputIndex( uint32_t newIndex ) const noexcept -> InputIndex;
291 auto outputItemStream( uint32_t index, ISequentialInStream** inStream ) const -> HRESULT;
293 auto indexInArchive( uint32_t index ) const noexcept -> uint32_t;
296 return mInputArchive.get();
300 mInputArchive = std::move( inputArchive );
303 inline auto inputArchiveItemsCount() const -> uint32_t {
304 return mInputArchiveItemsCount;
307 inline void setDeletedIndex( uint32_t index ) {
308 mDeletedItems.insert( index );
311 inline auto isDeletedIndex( uint32_t index )
const ->
bool {
312 return mDeletedItems.find( index ) != mDeletedItems.cend();
315 inline auto hasDeletedIndexes() const ->
bool {
316 return !mDeletedItems.empty();
319 inline auto hasNewItems() const ->
bool {
320 return mNewItemsVector.
size() > 0;
323 friend class UpdateCallback;
326 const BitAbstractArchiveCreator& mArchiveCreator;
328 unique_ptr< BitInputArchive > mInputArchive;
329 uint32_t mInputArchiveItemsCount;
331 BitItemsVector mNewItemsVector;
332 DeletedItems mDeletedItems;
334 mutable FailedFiles mFailedFiles;
349 auto initOutArchive() const -> CMyComPtr< IOutArchive >;
351 auto initOutFileStream( const fs::path& outArchive,
bool updatingArchive ) const -> CMyComPtr< IOutStream >;
354 const fs::path& inArc,
357 void compressToFile( const fs::path& outFile, UpdateCallback* updateCallback );
359 void compressOut( IOutArchive* outArc, IOutStream* outStream, UpdateCallback* updateCallback );
361 void setArchiveProperties( IOutArchive* outArchive ) const;
363 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...
BitOutputArchive(const BitAbstractArchiveCreator &creator, std::istream &inStream, ArchiveStartOffset startOffset=ArchiveStartOffset::None)
Constructs a BitOutputArchive object, reading an input file archive from the given std::istream.
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 compressTo(std::ostream &outStream)
Compresses all the items added to this object to the specified buffer.
void addFiles(const tstring &inDir, const tstring &filter, bool recursive)
Adds all the files inside the given directory path that match the given wildcard filter.
BitOutputArchive(const BitAbstractArchiveCreator &creator, const buffer_t &inBuffer, ArchiveStartOffset startOffset=ArchiveStartOffset::None)
Constructs a BitOutputArchive object, opening an input file archive from the given buffer.
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.
BitOutputArchive(const BitAbstractArchiveCreator &creator, const tstring &inFile, ArchiveStartOffset startOffset=ArchiveStartOffset::None)
Constructs a BitOutputArchive object, opening an (optional) input file archive.
void addDirectoryContents(const tstring &inDir, const tstring &filter, bool recursive)
Adds the contents of the given directory path.
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 addDirectoryContents(const tstring &inDir, const tstring &filter="*", FilterPolicy policy=FilterPolicy::Include, bool recursive=true)
Adds the contents of the given directory path.
void addItems(const std::vector< tstring > &inPaths)
Adds all the items that can be found by indexing the given vector of filesystem paths.
auto handler() const noexcept -> const BitAbstractArchiveHandler &
auto itemsCount() const -> uint32_t
void addDirectory(const tstring &inDir)
Adds the given directory path and all its content.
auto creator() const noexcept -> const BitAbstractArchiveCreator &
BitOutputArchive(const BitAbstractArchiveCreator &creator)
Constructs a BitOutputArchive object for a completely new archive.
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30
ArchiveStartOffset
Offset from where the archive starts within the input file.
Definition bitinputarchive.hpp:31
@ None
Don't specify an archive start offset.
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