10#ifndef BITOUTPUTARCHIVE_HPP
11#define BITOUTPUTARCHIVE_HPP
13#include "bitabstractarchivecreator.hpp"
14#include "bitabstractarchivehandler.hpp"
15#include "bitexception.hpp"
16#include "bitinputarchive.hpp"
17#include "bititemsvector.hpp"
18#include "bitpropvariant.hpp"
19#include "bittypes.hpp"
31struct ISequentialInStream;
39using DeletedItems = std::set< std::uint32_t >;
58enum class InputIndex : std::uint32_t {};
107 const buffer_t& inBuffer,
240 const tstring& filter = BIT7Z_STRING(
"*" ),
242 bool recursive =
true
280 const tstring& filter = BIT7Z_STRING(
"*" ),
282 bool recursive =
true
334 virtual auto itemStream( InputIndex index, ISequentialInStream** inStream ) const -> HRESULT;
336 virtual auto hasNewData( std::uint32_t index ) const noexcept ->
bool;
338 virtual auto hasNewProperties( std::uint32_t index ) const noexcept ->
bool;
340 auto itemInputIndex( std::uint32_t newIndex ) const noexcept -> InputIndex;
344 auto outputItemStream( std::uint32_t index, ISequentialInStream** inStream ) const -> HRESULT;
346 auto indexInArchive( std::uint32_t index ) const noexcept -> std::uint32_t;
349 return mInputArchive.get();
353 mInputArchive =
std::move( inputArchive );
356 auto inputArchiveItemsCount() const -> std::uint32_t {
357 return mInputArchiveItemsCount;
360 void setDeletedIndex( std::uint32_t index ) {
361 mDeletedItems.insert( index );
364 auto isDeletedIndex( std::uint32_t index )
const ->
bool {
365 return mDeletedItems.find( index ) != mDeletedItems.cend();
368 auto hasDeletedIndexes() const ->
bool {
369 return !mDeletedItems.empty();
372 auto hasNewItems() const ->
bool {
373 return !mNewItems.empty();
376 friend class UpdateCallback;
379 const BitAbstractArchiveCreator& mArchiveCreator;
381 std::unique_ptr< BitInputArchive > mInputArchive;
382 std::uint32_t mInputArchiveItemsCount;
385 DeletedItems mDeletedItems;
400 std::vector< InputIndex > mInputIndices;
402 auto initOutArchive() const -> CMyComPtr< IOutArchive >;
404 auto initOutFileStream( const bit7zfs::path& outArchive ) const -> CMyComPtr< IOutStream >;
407 const BitAbstractArchiveCreator&
creator,
408 const bit7zfs::path& inArc,
412 void compressToFile( const bit7zfs::path& outFile, UpdateCallback* updateCallback );
414 void compressOut( IOutArchive* outArc, IOutStream* outStream, UpdateCallback* updateCallback );
416 void setArchiveProperties( IOutArchive* outArchive ) const;
418 void updateInputIndices();
Abstract class representing a generic archive creator.
Definition bitabstractarchivecreator.hpp:57
Abstract class representing a generic archive handler.
Definition bitabstractarchivehandler.hpp:120
auto addFile(buffer_t &&inBuffer, const tstring &name) -> BitInputItem &=delete
Deleted overload preventing the addition of a temporary buffer.
auto addFile(const tstring &inFile, const tstring &name={}) -> BitInputItem &
Adds the given file path, with an optional user-defined path to be used in the output archive.
void compressTo(buffer_t &outBuffer)
Compresses all the items added to this object to the specified buffer.
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 filesystem paths map; the corr...
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 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.
auto addFile(std::istream &inStream, const tstring &name) -> BitInputItem &
Adds the given standard input stream, using the given name as a path when compressed in the output ar...
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.
auto itemsCount() const -> std::uint32_t
void compressTo(const tstring &outFile)
Compresses all the items added to this object to the specified archive file path.
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 addItems(const std::vector< std::pair< tstring, tstring > > &inPaths)
Adds all the items that can be found by indexing the keys of the given filesystem paths map; the corr...
BitOutputArchive(const BitAbstractArchiveCreator &creator, buffer_t &&inBuffer, ArchiveStartOffset startOffset=ArchiveStartOffset::None)=delete
Deleted overload preventing the use of a temporary input buffer.
void addDirectoryContents(const tstring &inDir, const tstring &filter="*", FilterPolicy policy=FilterPolicy::Include, bool recursive=true)
Adds the contents of the given directory path.
auto addFile(const buffer_t &inBuffer, const tstring &name) -> BitInputItem &
Adds the given buffer file, using the given name as a path when compressed in the output archive.
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 &
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:29
std::vector< BitInputItem > BitItemsVector
A vector of items to be compressed into an archive.
Definition bititemsvector.hpp:36
ArchiveStartOffset
Offset from where the archive starts within the input file.
Definition bitinputarchive.hpp:46
@ None
Don't specify an archive start offset.
Definition bitinputarchive.hpp:47
BitProperty
The BitProperty enum represents the archive/item properties that 7-zip can read or write.
Definition bitpropvariant.hpp:32
std::basic_string< tchar > tstring
Definition bittypes.hpp:104
FilterPolicy
Enumeration representing the policy according to which the archive handler should treat the items tha...
Definition bitabstractarchivehandler.hpp:112
@ Include
Extract/compress the items that match the pattern.
Definition bitabstractarchivehandler.hpp:113
std::vector< FailedFile > FailedFiles
An alias for a sequence of FailedFile entries.
Definition bitexception.hpp:33
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:161