diff --git a/include/bit7z/bitarchiveeditor.hpp b/include/bit7z/bitarchiveeditor.hpp index 6a880434..62e23f42 100644 --- a/include/bit7z/bitarchiveeditor.hpp +++ b/include/bit7z/bitarchiveeditor.hpp @@ -23,7 +23,6 @@ #include #include -#include namespace bit7z { @@ -102,7 +101,7 @@ class BIT7Z_MAYBE_UNUSED BitArchiveEditor final : public BitArchiveWriter { * @param index the index of the item to be updated. * @param inBuffer the buffer containing the new data for the item. */ - void updateItem( uint32_t index, const std::vector< byte_t >& inBuffer ); + void updateItem( uint32_t index, const buffer_t& inBuffer ); /** * @brief Requests to update the content of the item at the specified index @@ -129,7 +128,7 @@ class BIT7Z_MAYBE_UNUSED BitArchiveEditor final : public BitArchiveWriter { * @param itemPath the path (in the archive) of the item to be updated. * @param inBuffer the buffer containing the new data for the item. */ - void updateItem( const tstring& itemPath, const std::vector< byte_t >& inBuffer ); + void updateItem( const tstring& itemPath, const buffer_t& inBuffer ); /** * @brief Requests to update the content of the item at the specified path diff --git a/include/bit7z/bitarchivereader.hpp b/include/bit7z/bitarchivereader.hpp index 137f2bb8..9e8d1394 100644 --- a/include/bit7z/bitarchivereader.hpp +++ b/include/bit7z/bitarchivereader.hpp @@ -23,7 +23,6 @@ #include #include #include -#include struct IInArchive; struct IOutArchive; @@ -68,7 +67,7 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA * @param password the password needed for opening the input archive. */ BitArchiveReader( const Bit7zLibrary& lib, - const std::vector< byte_t >& inArchive, + const buffer_t& inArchive, const BitInFormat& format BIT7Z_DEFAULT_FORMAT, const tstring& password = {} ); diff --git a/include/bit7z/bitarchivewriter.hpp b/include/bit7z/bitarchivewriter.hpp index 6aeccf08..712dba7f 100644 --- a/include/bit7z/bitarchivewriter.hpp +++ b/include/bit7z/bitarchivewriter.hpp @@ -17,7 +17,6 @@ #include "bittypes.hpp" #include -#include namespace bit7z { @@ -56,7 +55,7 @@ class BitArchiveWriter : public BitAbstractArchiveCreator, public BitOutputArchi * @param password (optional) the password needed to read the input archive. */ BitArchiveWriter( const Bit7zLibrary& lib, - const std::vector< byte_t >& inArchive, + const buffer_t& inArchive, const BitInOutFormat& format, const tstring& password = {} ); diff --git a/include/bit7z/bitcompressor.hpp b/include/bit7z/bitcompressor.hpp index 2ec42730..3b8595bc 100644 --- a/include/bit7z/bitcompressor.hpp +++ b/include/bit7z/bitcompressor.hpp @@ -21,7 +21,6 @@ #include #include -#include namespace bit7z { @@ -90,7 +89,7 @@ class BitCompressor : public BitAbstractArchiveCreator { * @param inputName (optional) the name to give to the compressed file inside the output archive. */ void compressFile( Input inFile, - std::vector< byte_t >& outBuffer, + buffer_t& outBuffer, const tstring& inputName = {} ) const { BitOutputArchive outputArchive{ *this, outBuffer }; outputArchive.addFile( inFile, inputName ); diff --git a/include/bit7z/bitextractor.hpp b/include/bit7z/bitextractor.hpp index 5d5b462b..d7c5277f 100644 --- a/include/bit7z/bitextractor.hpp +++ b/include/bit7z/bitextractor.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #ifdef BIT7Z_REGEX_MATCHING @@ -81,7 +80,7 @@ class BitExtractor final : public BitAbstractArchiveOpener { * @param outBuffer the output buffer where the content of the extracted file will be put. * @param index the index of the file to be extracted from the archive. */ - void extract( Input inArchive, std::vector< byte_t >& outBuffer, uint32_t index = 0 ) const { + void extract( Input inArchive, buffer_t& outBuffer, uint32_t index = 0 ) const { BitInputArchive inputArchive( *this, inArchive ); inputArchive.extractTo( outBuffer, index ); } @@ -105,7 +104,7 @@ class BitExtractor final : public BitAbstractArchiveOpener { * @param inArchive the input archive to be extracted. * @param outMap the output map. */ - void extract( Input inArchive, std::map< tstring, std::vector< byte_t > >& outMap ) const { + void extract( Input inArchive, std::map< tstring, buffer_t >& outMap ) const { BitInputArchive inputArchive( *this, inArchive ); inputArchive.extractTo( outMap ); } @@ -141,7 +140,7 @@ class BitExtractor final : public BitAbstractArchiveOpener { */ void extractMatching( Input inArchive, const tstring& itemFilter, - std::vector< byte_t >& outBuffer, + buffer_t& outBuffer, FilterPolicy policy = FilterPolicy::Include ) const { if ( itemFilter.empty() ) { throw BitException( "Cannot extract items", make_error_code( BitError::FilterNotSpecified ) ); @@ -221,7 +220,7 @@ class BitExtractor final : public BitAbstractArchiveOpener { */ void extractMatchingRegex( Input inArchive, const tstring& regex, - std::vector< byte_t >& outBuffer, + buffer_t& outBuffer, FilterPolicy policy = FilterPolicy::Include ) const { if ( regex.empty() ) { throw BitException( "Cannot extract items", make_error_code( BitError::FilterNotSpecified ) ); @@ -278,7 +277,7 @@ class BitExtractor final : public BitAbstractArchiveOpener { } void extractMatchingFilter( Input inArchive, - std::vector< byte_t >& outBuffer, + buffer_t& outBuffer, FilterPolicy policy, const std::function< bool( const tstring& ) >& filter ) const { BitInputArchive inputArchive( *this, inArchive ); diff --git a/include/bit7z/bitinputarchive.hpp b/include/bit7z/bitinputarchive.hpp index 1d5b87b7..b24821ab 100644 --- a/include/bit7z/bitinputarchive.hpp +++ b/include/bit7z/bitinputarchive.hpp @@ -25,7 +25,6 @@ #include #include #include -#include struct IInStream; struct IInArchive; @@ -63,7 +62,7 @@ class BitInputArchive { * be used for reading the input archive * @param inBuffer the buffer containing the input archive */ - BitInputArchive( const BitAbstractArchiveHandler& handler, const std::vector< byte_t >& inBuffer ); + BitInputArchive( const BitAbstractArchiveHandler& handler, const buffer_t& inBuffer ); /** * @brief Constructs a BitInputArchive object, opening the archive by reading the given input stream. @@ -152,7 +151,7 @@ class BitInputArchive { void extractTo( const tstring& outDir, const std::vector< uint32_t >& indices = {} ) const; BIT7Z_DEPRECATED_MSG("Since v4.0; please, use the extractTo method.") - inline void extract( std::vector< byte_t >& outBuffer, uint32_t index = 0 ) const { + inline void extract( buffer_t& outBuffer, uint32_t index = 0 ) const { extractTo( outBuffer, index ); } @@ -162,7 +161,7 @@ class BitInputArchive { * @param outBuffer the output buffer where the content of the archive will be put. * @param index the index of the file to be extracted. */ - void extractTo( std::vector< byte_t >& outBuffer, uint32_t index = 0 ) const; + void extractTo( buffer_t& outBuffer, uint32_t index = 0 ) const; template< std::size_t N > BIT7Z_DEPRECATED_MSG("Since v4.0; please, use the extractTo method.") @@ -231,7 +230,7 @@ class BitInputArchive { void extractTo( std::ostream& outStream, uint32_t index = 0 ) const; BIT7Z_DEPRECATED_MSG("Since v4.0; please, use the extractTo method.") - inline void extract( std::map< tstring, std::vector< byte_t > >& outMap ) const { + inline void extract( std::map< tstring, buffer_t >& outMap ) const { extractTo( outMap ); } @@ -241,7 +240,7 @@ class BitInputArchive { * * @param outMap the output map. */ - void extractTo( std::map< tstring, std::vector< byte_t > >& outMap ) const; + void extractTo( std::map< tstring, buffer_t >& outMap ) const; /** * @brief Tests the archive without extracting its content. diff --git a/include/bit7z/bititemsvector.hpp b/include/bit7z/bititemsvector.hpp index cba60d92..b896ccc6 100644 --- a/include/bit7z/bititemsvector.hpp +++ b/include/bit7z/bititemsvector.hpp @@ -18,7 +18,6 @@ #include #include #include -#include namespace bit7z { @@ -113,7 +112,7 @@ class BitItemsVector final { * @param inBuffer the buffer containing the file to be indexed in the vector. * @param name user-defined path to be used inside archives. */ - void indexBuffer( const std::vector< byte_t >& inBuffer, const tstring& name ); + void indexBuffer( const buffer_t& inBuffer, const tstring& name ); /** * @brief Indexes the given standard input stream, using the given name as a path when compressed in archives. diff --git a/include/bit7z/bitmemcompressor.hpp b/include/bit7z/bitmemcompressor.hpp index 2b91ad9b..97ac001a 100644 --- a/include/bit7z/bitmemcompressor.hpp +++ b/include/bit7z/bitmemcompressor.hpp @@ -14,8 +14,6 @@ #include "bitdefines.hpp" #include "bittypes.hpp" -#include - namespace bit7z { /** @@ -25,7 +23,7 @@ namespace bit7z { * It let decide various properties of the produced archive, such as the password * protection and the compression level desired. */ -using BitMemCompressor BIT7Z_MAYBE_UNUSED = BitCompressor< const std::vector< byte_t >& >; +using BitMemCompressor BIT7Z_MAYBE_UNUSED = BitCompressor< const buffer_t& >; } // namespace bit7z #endif // BITMEMCOMPRESSOR_HPP diff --git a/include/bit7z/bitmemextractor.hpp b/include/bit7z/bitmemextractor.hpp index 97742797..d0afcce9 100644 --- a/include/bit7z/bitmemextractor.hpp +++ b/include/bit7z/bitmemextractor.hpp @@ -14,14 +14,12 @@ #include "bitextractor.hpp" #include "bittypes.hpp" -#include - namespace bit7z { /** * @brief The BitMemExtractor alias allows extracting the content of in-memory archives. */ -using BitMemExtractor BIT7Z_MAYBE_UNUSED = BitExtractor< const std::vector< byte_t >& >; +using BitMemExtractor BIT7Z_MAYBE_UNUSED = BitExtractor< const buffer_t& >; } // namespace bit7z diff --git a/include/bit7z/bitoutputarchive.hpp b/include/bit7z/bitoutputarchive.hpp index 6ed7f00c..c2e5b5fc 100644 --- a/include/bit7z/bitoutputarchive.hpp +++ b/include/bit7z/bitoutputarchive.hpp @@ -24,7 +24,6 @@ #include #include #include -#include //! @cond IGNORE_BLOCK_IN_DOXYGEN struct ISequentialInStream; @@ -95,7 +94,7 @@ class BitOutputArchive { * be used for creating the new archive and reading the (optional) input archive. * @param inBuffer the buffer containing an input archive file. */ - BitOutputArchive( const BitAbstractArchiveCreator& creator, const std::vector< byte_t >& inBuffer ); + BitOutputArchive( const BitAbstractArchiveCreator& creator, const buffer_t& inBuffer ); /** * @brief Constructs a BitOutputArchive object, reading an input file archive from the given std::istream. @@ -146,7 +145,7 @@ class BitOutputArchive { * @param inBuffer the buffer containing the file to be added to the output archive. * @param name user-defined path to be used inside the output archive. */ - void addFile( const std::vector< byte_t >& inBuffer, const tstring& name ); + void addFile( const buffer_t& inBuffer, const tstring& name ); /** * @brief Adds the given standard input stream, using the given name as a path when compressed @@ -214,7 +213,7 @@ class BitOutputArchive { * * @param outBuffer the output buffer. */ - void compressTo( std::vector< byte_t >& outBuffer ); + void compressTo( buffer_t& outBuffer ); /** * @brief Compresses all the items added to this object to the specified buffer. diff --git a/src/bitarchiveeditor.cpp b/src/bitarchiveeditor.cpp index b87ce893..9fcd2ad0 100644 --- a/src/bitarchiveeditor.cpp +++ b/src/bitarchiveeditor.cpp @@ -36,7 +36,6 @@ #include #include #include -#include namespace bit7z { @@ -81,7 +80,7 @@ void BitArchiveEditor::updateItem( uint32_t index, const tstring& inFile ) { mEditedItems[ index ] = std::make_unique< FilesystemItem >( tstring_to_path( inFile ), itemName.getNativeString() ); //-V108 } -void BitArchiveEditor::updateItem( uint32_t index, const std::vector< byte_t >& inBuffer ) { +void BitArchiveEditor::updateItem( uint32_t index, const buffer_t& inBuffer ) { checkIndex( index ); auto itemName = inputArchive()->itemProperty( index, BitProperty::Path ); mEditedItems[ index ] = std::make_unique< BufferItem >( inBuffer, itemName.getNativeString() ); //-V108 @@ -98,7 +97,7 @@ void BitArchiveEditor::updateItem( const tstring& itemPath, const tstring& inFil tstring_to_path( itemPath ) ); } -void BitArchiveEditor::updateItem( const tstring& itemPath, const std::vector< byte_t >& inBuffer ) { +void BitArchiveEditor::updateItem( const tstring& itemPath, const buffer_t& inBuffer ) { mEditedItems[ findItem( itemPath ) ] = std::make_unique< BufferItem >( inBuffer, itemPath ); //-V108 } diff --git a/src/bitarchivereader.cpp b/src/bitarchivereader.cpp index 7e646b69..e04431a4 100644 --- a/src/bitarchivereader.cpp +++ b/src/bitarchivereader.cpp @@ -27,7 +27,6 @@ #include #include #include -#include namespace bit7z { @@ -38,7 +37,7 @@ BitArchiveReader::BitArchiveReader( const Bit7zLibrary& lib, : BitAbstractArchiveOpener( lib, format, password ), BitInputArchive( *this, inArchive ) {} BitArchiveReader::BitArchiveReader( const Bit7zLibrary& lib, - const std::vector< byte_t >& inArchive, + const buffer_t& inArchive, const BitInFormat& format, const tstring& password ) : BitAbstractArchiveOpener( lib, format, password ), BitInputArchive( *this, inArchive ) {} diff --git a/src/bitarchivewriter.cpp b/src/bitarchivewriter.cpp index 39dbc953..322dada2 100644 --- a/src/bitarchivewriter.cpp +++ b/src/bitarchivewriter.cpp @@ -19,7 +19,6 @@ #include "bittypes.hpp" #include -#include namespace bit7z { @@ -34,7 +33,7 @@ BitArchiveWriter::BitArchiveWriter( const Bit7zLibrary& lib, BitOutputArchive( *this, inArchive ) {} BitArchiveWriter::BitArchiveWriter( const Bit7zLibrary& lib, - const std::vector< byte_t >& inArchive, + const buffer_t& inArchive, const BitInOutFormat& format, const tstring& password ) : BitAbstractArchiveCreator( lib, format, password, UpdateMode::Append ), diff --git a/src/bitinputarchive.cpp b/src/bitinputarchive.cpp index 51e1323f..94be5418 100644 --- a/src/bitinputarchive.cpp +++ b/src/bitinputarchive.cpp @@ -132,7 +132,7 @@ BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, cons mInArchive = openArchiveStream( arcPath, fileStream ); } -BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, const std::vector< byte_t >& inBuffer ) +BitInputArchive::BitInputArchive( const BitAbstractArchiveHandler& handler, const buffer_t& inBuffer ) : mDetectedFormat{ &handler.format() }, // if auto, detect the format from content, otherwise try the passed format. mArchiveHandler{ handler } { auto bufStream = bit7z::make_com< CBufferInStream, IInStream >( inBuffer ); @@ -215,7 +215,7 @@ void BitInputArchive::extractTo( const tstring& outDir, const std::vector< uint3 extract_arc( mInArchive, indices, callback ); } -void BitInputArchive::extractTo( std::vector< byte_t >& outBuffer, uint32_t index ) const { +void BitInputArchive::extractTo( buffer_t& outBuffer, uint32_t index ) const { const uint32_t numberItems = itemsCount(); if ( index >= numberItems ) { throw BitException( "Cannot extract item at the index " + std::to_string( index ), @@ -228,7 +228,7 @@ void BitInputArchive::extractTo( std::vector< byte_t >& outBuffer, uint32_t inde } const std::vector< uint32_t > indices( 1, index ); - std::map< tstring, std::vector< byte_t > > buffersMap; + std::map< tstring, buffer_t > buffersMap; auto extractCallback = bit7z::make_com< BufferExtractCallback, ExtractCallback >( *this, buffersMap ); extract_arc( mInArchive, indices, extractCallback ); outBuffer = std::move( buffersMap.begin()->second ); @@ -274,7 +274,7 @@ void BitInputArchive::extractTo( byte_t* buffer, std::size_t size, uint32_t inde extract_arc( mInArchive, indices, extractCallback ); } -void BitInputArchive::extractTo( std::map< tstring, std::vector< byte_t > >& outMap ) const { +void BitInputArchive::extractTo( std::map< tstring, buffer_t >& outMap ) const { const uint32_t numberItems = itemsCount(); std::vector< uint32_t > filesIndices; for ( uint32_t i = 0; i < numberItems; ++i ) { @@ -288,7 +288,7 @@ void BitInputArchive::extractTo( std::map< tstring, std::vector< byte_t > >& out } void BitInputArchive::test() const { - std::map< tstring, std::vector< byte_t > > dummyMap; // output map (not used since we are testing). + std::map< tstring, buffer_t > dummyMap; // output map (not used since we are testing). auto extractCallback = bit7z::make_com< BufferExtractCallback, ExtractCallback >( *this, dummyMap ); extract_arc( mInArchive, {}, extractCallback, ExtractMode::Test ); } @@ -300,7 +300,7 @@ void BitInputArchive::testItem( uint32_t index ) const { make_error_code( BitError::InvalidIndex ) ); } - std::map< tstring, std::vector< byte_t > > dummyMap; // output map (not used since we are testing). + std::map< tstring, buffer_t > dummyMap; // output map (not used since we are testing). auto extractCallback = bit7z::make_com< BufferExtractCallback, ExtractCallback >( *this, dummyMap ); extract_arc( mInArchive, { index }, extractCallback, ExtractMode::Test ); } diff --git a/src/bititemsvector.cpp b/src/bititemsvector.cpp index 96bfb38f..951b3947 100644 --- a/src/bititemsvector.cpp +++ b/src/bititemsvector.cpp @@ -93,7 +93,7 @@ void BitItemsVector::indexFile( const tstring& inFile, const tstring& name, bool mItems.emplace_back( std::make_unique< FilesystemItem >( filePath, tstring_to_path( name ), symlinkPolicy ) ); } -void BitItemsVector::indexBuffer( const std::vector< byte_t >& inBuffer, const tstring& name ) { +void BitItemsVector::indexBuffer( const buffer_t& inBuffer, const tstring& name ) { mItems.emplace_back( std::make_unique< BufferItem >( inBuffer, tstring_to_path( name ) ) ); } diff --git a/src/bitoutputarchive.cpp b/src/bitoutputarchive.cpp index 61d797a3..41fb409b 100644 --- a/src/bitoutputarchive.cpp +++ b/src/bitoutputarchive.cpp @@ -78,8 +78,7 @@ BitOutputArchive::BitOutputArchive( const BitAbstractArchiveCreator& creator, co mInputArchiveItemsCount = mInputArchive->itemsCount(); } -BitOutputArchive::BitOutputArchive( const BitAbstractArchiveCreator& creator, - const std::vector< bit7z::byte_t >& inBuffer ) +BitOutputArchive::BitOutputArchive( const BitAbstractArchiveCreator& creator, const buffer_t& inBuffer ) : mArchiveCreator{ creator }, mInputArchiveItemsCount{ 0 } { if ( !inBuffer.empty() ) { mInputArchive = std::make_unique< BitInputArchive >( creator, inBuffer ); @@ -114,7 +113,7 @@ void BitOutputArchive::addFile( const tstring& inFile, const tstring& name ) { !mArchiveCreator.storeSymbolicLinks() ); } -void BitOutputArchive::addFile( const std::vector< byte_t >& inBuffer, const tstring& name ) { +void BitOutputArchive::addFile( const buffer_t& inBuffer, const tstring& name ) { mNewItemsVector.indexBuffer( inBuffer, name ); } @@ -258,7 +257,7 @@ void BitOutputArchive::compressTo( const tstring& outFile ) { compressToFile( outPath, updateCallback ); } -void BitOutputArchive::compressTo( std::vector< byte_t >& outBuffer ) { +void BitOutputArchive::compressTo( buffer_t& outBuffer ) { if ( !outBuffer.empty() ) { const OverwriteMode overwriteMode = mArchiveCreator.overwriteMode(); if ( overwriteMode == OverwriteMode::Skip ) { diff --git a/src/internal/bufferextractcallback.cpp b/src/internal/bufferextractcallback.cpp index 3f011570..a1f74f5b 100644 --- a/src/internal/bufferextractcallback.cpp +++ b/src/internal/bufferextractcallback.cpp @@ -25,7 +25,7 @@ namespace bit7z { BufferExtractCallback::BufferExtractCallback( const BitInputArchive& inputArchive, - std::map< tstring, std::vector< byte_t > >& buffersMap ) + std::map< tstring, buffer_t >& buffersMap ) : ExtractCallback( inputArchive ), mBuffersMap( buffersMap ) {} diff --git a/src/internal/bufferextractcallback.hpp b/src/internal/bufferextractcallback.hpp index 8c2c7f13..58bcc2f0 100644 --- a/src/internal/bufferextractcallback.hpp +++ b/src/internal/bufferextractcallback.hpp @@ -10,19 +10,20 @@ #ifndef BUFFEREXTRACTCALLBACK_HPP #define BUFFEREXTRACTCALLBACK_HPP -#include "bitinputarchive.hpp" #include "bittypes.hpp" #include "internal/extractcallback.hpp" -#include +#include #include namespace bit7z { +class BitInputArchive; + class BufferExtractCallback final : public ExtractCallback { public: BufferExtractCallback( const BitInputArchive& inputArchive, - std::map< tstring, std::vector< byte_t > >& buffersMap ); + std::map< tstring, buffer_t >& buffersMap ); BufferExtractCallback( const BufferExtractCallback& ) = delete; @@ -35,7 +36,7 @@ class BufferExtractCallback final : public ExtractCallback { ~BufferExtractCallback() override = default; private: - std::map< tstring, std::vector< byte_t > >& mBuffersMap; + std::map< tstring, buffer_t >& mBuffersMap; CMyComPtr< ISequentialOutStream > mOutMemStream; void releaseStream() override; diff --git a/src/internal/bufferitem.cpp b/src/internal/bufferitem.cpp index 7b036252..448afc79 100644 --- a/src/internal/bufferitem.cpp +++ b/src/internal/bufferitem.cpp @@ -21,11 +21,10 @@ #include #include -#include namespace bit7z { -BufferItem::BufferItem( const std::vector< byte_t >& buffer, fs::path name ) +BufferItem::BufferItem( const buffer_t& buffer, fs::path name ) : mBuffer{ buffer }, mBufferName{ std::move( name ) } {} auto BufferItem::name() const -> tstring { diff --git a/src/internal/bufferitem.hpp b/src/internal/bufferitem.hpp index 52ec4d3e..2e2dd634 100644 --- a/src/internal/bufferitem.hpp +++ b/src/internal/bufferitem.hpp @@ -18,7 +18,7 @@ namespace bit7z { class BufferItem final : public GenericInputItem { public: - explicit BufferItem( const std::vector< byte_t >& buffer, fs::path name ); + explicit BufferItem( const buffer_t& buffer, fs::path name ); BIT7Z_NODISCARD auto name() const -> tstring override; @@ -41,7 +41,7 @@ class BufferItem final : public GenericInputItem { BIT7Z_NODISCARD auto attributes() const noexcept -> uint32_t override; private: - const std::vector< byte_t >& mBuffer; + const buffer_t& mBuffer; fs::path mBufferName; }; diff --git a/src/internal/callback.hpp b/src/internal/callback.hpp index 85e7cbf1..3fc2f0ac 100644 --- a/src/internal/callback.hpp +++ b/src/internal/callback.hpp @@ -10,7 +10,6 @@ #ifndef CALLBACK_HPP #define CALLBACK_HPP -#include "bitabstractarchivehandler.hpp" #include "internal/com.hpp" #include "internal/guids.hpp" @@ -28,6 +27,8 @@ namespace bit7z { # define CALLBACK_DESTRUCTOR( x ) virtual x #endif +class BitAbstractArchiveHandler; + class Callback : protected CMyUnknownImp { public: Callback( const Callback& ) = delete; diff --git a/src/internal/cbufferinstream.cpp b/src/internal/cbufferinstream.cpp index f0763e35..1efdd79c 100644 --- a/src/internal/cbufferinstream.cpp +++ b/src/internal/cbufferinstream.cpp @@ -26,7 +26,7 @@ namespace bit7z { -CBufferInStream::CBufferInStream( const std::vector< byte_t >& inBuffer ) +CBufferInStream::CBufferInStream( const buffer_t& inBuffer ) : mBuffer( inBuffer ), mCurrentPosition{ mBuffer.begin() } {} COM_DECLSPEC_NOTHROW diff --git a/src/internal/cbufferinstream.hpp b/src/internal/cbufferinstream.hpp index 0ad2ec64..8669e235 100644 --- a/src/internal/cbufferinstream.hpp +++ b/src/internal/cbufferinstream.hpp @@ -17,13 +17,11 @@ #include <7zip/IStream.h> -#include - namespace bit7z { class CBufferInStream final : public IInStream, public CMyUnknownImp { public: - explicit CBufferInStream( const std::vector< byte_t >& inBuffer ); + explicit CBufferInStream( const buffer_t& inBuffer ); CBufferInStream( const CBufferInStream& ) = delete; diff --git a/src/internal/cbufferoutstream.cpp b/src/internal/cbufferoutstream.cpp index 17a44cfd..4181c86e 100644 --- a/src/internal/cbufferoutstream.cpp +++ b/src/internal/cbufferoutstream.cpp @@ -21,13 +21,13 @@ namespace bit7z { -CBufferOutStream::CBufferOutStream( std::vector< byte_t >& outBuffer ) +CBufferOutStream::CBufferOutStream( buffer_t& outBuffer ) : mBuffer( outBuffer ), mCurrentPosition{ mBuffer.begin() } {} COM_DECLSPEC_NOTHROW STDMETHODIMP CBufferOutStream::SetSize( UInt64 newSize ) noexcept { try { - mBuffer.resize( static_cast< std::vector< byte_t >::size_type >( newSize ) ); + mBuffer.resize( static_cast< buffer_t::size_type >( newSize ) ); return S_OK; } catch ( ... ) { return E_OUTOFMEMORY; diff --git a/src/internal/cbufferoutstream.hpp b/src/internal/cbufferoutstream.hpp index ad6705b3..b2b1282d 100644 --- a/src/internal/cbufferoutstream.hpp +++ b/src/internal/cbufferoutstream.hpp @@ -21,7 +21,7 @@ namespace bit7z { class CBufferOutStream final : public IOutStream, public CMyUnknownImp { public: - explicit CBufferOutStream( std::vector< byte_t >& outBuffer ); + explicit CBufferOutStream( buffer_t& outBuffer ); CBufferOutStream( const CBufferOutStream& ) = delete; diff --git a/src/internal/cmultivolumeoutstream.hpp b/src/internal/cmultivolumeoutstream.hpp index f2a44447..1a644d9e 100644 --- a/src/internal/cmultivolumeoutstream.hpp +++ b/src/internal/cmultivolumeoutstream.hpp @@ -17,7 +17,6 @@ #include <7zip/IStream.h> #include -#include #include namespace bit7z { diff --git a/src/internal/dateutil.hpp b/src/internal/dateutil.hpp index 43cd2edf..37724b26 100644 --- a/src/internal/dateutil.hpp +++ b/src/internal/dateutil.hpp @@ -14,8 +14,9 @@ #include "bitwindows.hpp" #include "internal/fs.hpp" -#include +#ifndef _WIN32 #include +#endif namespace bit7z { diff --git a/src/internal/extractcallback.cpp b/src/internal/extractcallback.cpp index c1c31c12..a1644d59 100644 --- a/src/internal/extractcallback.cpp +++ b/src/internal/extractcallback.cpp @@ -12,7 +12,9 @@ #include "internal/extractcallback.hpp" +#include "bitabstractarchivehandler.hpp" #include "bitexception.hpp" +#include "bitinputarchive.hpp" #include "internal/operationcategory.hpp" #include "internal/stringutil.hpp" @@ -140,4 +142,24 @@ STDMETHODIMP ExtractCallback::CryptoGetTextPassword( BSTR* password ) noexcept { return StringToBstr( pass.c_str(), password ); } +auto ExtractCallback::isItemFolder( uint32_t index ) const -> bool { + return mInputArchive.isItemFolder( index ); +} + +auto ExtractCallback::itemProperty( uint32_t index, BitProperty property ) const -> BitPropVariant { + return mInputArchive.itemProperty( index, property ); +} + +auto ExtractCallback::inputArchive() const -> const BitInputArchive& { + return mInputArchive; +} + +auto ExtractCallback::errorException() const -> const std::exception_ptr& { + return mErrorException; +} + +auto ExtractCallback::extractMode() const -> ExtractMode { + return mExtractMode; +} + } // namespace bit7z diff --git a/src/internal/extractcallback.hpp b/src/internal/extractcallback.hpp index f6086c91..8f41d88f 100644 --- a/src/internal/extractcallback.hpp +++ b/src/internal/extractcallback.hpp @@ -10,7 +10,7 @@ #ifndef EXTRACTCALLBACK_HPP #define EXTRACTCALLBACK_HPP -#include "bitinputarchive.hpp" +#include "bitpropvariant.hpp" #include "internal/callback.hpp" #include "internal/macros.hpp" #include "internal/operationresult.hpp" @@ -25,6 +25,8 @@ using namespace NArchive::NExtract; namespace bit7z { +class BitInputArchive; + constexpr auto kEmptyFileAlias = BIT7Z_STRING( "[Content]" ); enum struct ExtractMode { @@ -68,9 +70,7 @@ class ExtractCallback : public Callback, BIT7Z_STDMETHOD( SetOperationResult, Int32 operationResult ); BIT7Z_NODISCARD - inline auto errorException() const -> const std::exception_ptr& { - return mErrorException; - } + auto errorException() const -> const std::exception_ptr&; // NOLINTNEXTLINE(modernize-use-noexcept, modernize-use-trailing-return-type, readability-identifier-length) MY_UNKNOWN_IMP3( IArchiveExtractCallback, ICompressProgressInfo, ICryptoGetTextPassword ) //-V2507 //-V2511 //-V835 @@ -79,24 +79,16 @@ class ExtractCallback : public Callback, explicit ExtractCallback( const BitInputArchive& inputArchive ); BIT7Z_NODISCARD - inline auto extractMode() const -> ExtractMode { - return mExtractMode; - } + auto extractMode() const -> ExtractMode; BIT7Z_NODISCARD - inline auto isItemFolder( uint32_t index ) const -> bool { - return mInputArchive.isItemFolder( index ); - } + auto isItemFolder( uint32_t index ) const -> bool; BIT7Z_NODISCARD - inline auto itemProperty( uint32_t index, BitProperty property ) const -> BitPropVariant { - return mInputArchive.itemProperty( index, property ); - } + auto itemProperty( uint32_t index, BitProperty property ) const -> BitPropVariant; BIT7Z_NODISCARD - inline auto inputArchive() const -> const BitInputArchive& { - return mInputArchive; - } + auto inputArchive() const -> const BitInputArchive&; virtual auto finishOperation( OperationResult operationResult ) -> HRESULT; diff --git a/src/internal/fileextractcallback.cpp b/src/internal/fileextractcallback.cpp index 063320f3..1095e7be 100644 --- a/src/internal/fileextractcallback.cpp +++ b/src/internal/fileextractcallback.cpp @@ -13,6 +13,7 @@ #include "internal/fileextractcallback.hpp" #include "bitexception.hpp" +#include "bitinputarchive.hpp" #include "internal/fsutil.hpp" #include "internal/stringutil.hpp" #include "internal/util.hpp" diff --git a/src/internal/fileextractcallback.hpp b/src/internal/fileextractcallback.hpp index 6226e15f..d5c989d2 100644 --- a/src/internal/fileextractcallback.hpp +++ b/src/internal/fileextractcallback.hpp @@ -16,6 +16,8 @@ namespace bit7z { +class BitInputArchive; + class FileExtractCallback final : public ExtractCallback { public: FileExtractCallback( const BitInputArchive& inputArchive, const tstring& directoryPath ); diff --git a/src/internal/fixedbufferextractcallback.cpp b/src/internal/fixedbufferextractcallback.cpp index d97b8011..07a2f5f9 100644 --- a/src/internal/fixedbufferextractcallback.cpp +++ b/src/internal/fixedbufferextractcallback.cpp @@ -12,6 +12,7 @@ #include "internal/fixedbufferextractcallback.hpp" +#include "bitabstractarchivehandler.hpp" #include "internal/cfixedbufferoutstream.hpp" #include "internal/util.hpp" diff --git a/src/internal/fixedbufferextractcallback.hpp b/src/internal/fixedbufferextractcallback.hpp index e6c26d21..04e26114 100644 --- a/src/internal/fixedbufferextractcallback.hpp +++ b/src/internal/fixedbufferextractcallback.hpp @@ -15,6 +15,8 @@ namespace bit7z { +class BitInputArchive; + class FixedBufferExtractCallback final : public ExtractCallback { public: FixedBufferExtractCallback( const BitInputArchive& inputArchive, byte_t* buffer, size_t size ); diff --git a/src/internal/formatdetect.cpp b/src/internal/formatdetect.cpp index 8b5944d7..5ab750c7 100644 --- a/src/internal/formatdetect.cpp +++ b/src/internal/formatdetect.cpp @@ -18,6 +18,7 @@ #include "biterror.hpp" #include "bitexception.hpp" +#include "bitformat.hpp" #include "internal/fsutil.hpp" #ifndef _WIN32 #include "internal/guiddef.hpp" diff --git a/src/internal/formatdetect.hpp b/src/internal/formatdetect.hpp index e0774f0a..67c497c6 100644 --- a/src/internal/formatdetect.hpp +++ b/src/internal/formatdetect.hpp @@ -14,13 +14,14 @@ #ifdef BIT7Z_AUTO_FORMAT -#include "bitformat.hpp" #include "bitfs.hpp" struct IInStream; namespace bit7z { +class BitInFormat; + auto detect_format_from_extension( const fs::path& inFile ) -> const BitInFormat&; auto detect_format_from_signature( IInStream * stream ) -> const BitInFormat&; diff --git a/src/internal/hresultcategory.cpp b/src/internal/hresultcategory.cpp index 064660c8..f26eed7c 100644 --- a/src/internal/hresultcategory.cpp +++ b/src/internal/hresultcategory.cpp @@ -22,7 +22,7 @@ auto HRESULTCategory::name() const noexcept -> const char* { auto HRESULTCategory::message( int errorValue ) const -> std::string { #ifdef _WIN32 - // Note: also MinGW supports FormatMessageA! + // Note: also MinGW supports FormatMessageA, so we use it. LPSTR messageBuffer = nullptr; auto msgSize = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | diff --git a/src/internal/opencallback.cpp b/src/internal/opencallback.cpp index 57b4684c..94cff104 100644 --- a/src/internal/opencallback.cpp +++ b/src/internal/opencallback.cpp @@ -12,6 +12,7 @@ #include "internal/opencallback.hpp" +#include "bitabstractarchivehandler.hpp" #include "bitexception.hpp" #include "internal/cfileinstream.hpp" #include "internal/stringutil.hpp" diff --git a/src/internal/opencallback.hpp b/src/internal/opencallback.hpp index 824c2d60..baffd6f3 100644 --- a/src/internal/opencallback.hpp +++ b/src/internal/opencallback.hpp @@ -10,7 +10,6 @@ #ifndef OPENCALLBACK_HPP #define OPENCALLBACK_HPP -#include "bitabstractarchivehandler.hpp" #include "internal/callback.hpp" #include "internal/com.hpp" #include "internal/fsitem.hpp" @@ -23,6 +22,8 @@ namespace bit7z { using filesystem::FilesystemItem; +class BitAbstractArchiveHandler; + class OpenCallback final : public IArchiveOpenCallback, public IArchiveOpenVolumeCallback, public IArchiveOpenSetSubArchiveName, diff --git a/src/internal/processeditem.cpp b/src/internal/processeditem.cpp index 621cb448..272a15b0 100644 --- a/src/internal/processeditem.cpp +++ b/src/internal/processeditem.cpp @@ -13,6 +13,8 @@ #include "internal/processeditem.hpp" #include "bitexception.hpp" +#include "bitinputarchive.hpp" +#include "bitpropvariant.hpp" namespace bit7z { diff --git a/src/internal/processeditem.hpp b/src/internal/processeditem.hpp index e87d92b8..57e7b89a 100644 --- a/src/internal/processeditem.hpp +++ b/src/internal/processeditem.hpp @@ -10,12 +10,13 @@ #ifndef PROCESSEDITEM_HPP #define PROCESSEDITEM_HPP -#include "bitinputarchive.hpp" #include "internal/fs.hpp" #include "internal/windows.hpp" namespace bit7z { +class BitInputArchive; + class ProcessedItem final { public: ProcessedItem(); diff --git a/src/internal/renameditem.cpp b/src/internal/renameditem.cpp index df43e123..fedd6535 100644 --- a/src/internal/renameditem.cpp +++ b/src/internal/renameditem.cpp @@ -12,6 +12,7 @@ #include "internal/renameditem.hpp" +#include "bitinputarchive.hpp" #include "internal/dateutil.hpp" #include "internal/fsutil.hpp" #include "internal/stringutil.hpp" diff --git a/src/internal/renameditem.hpp b/src/internal/renameditem.hpp index ad729932..939f1bf2 100644 --- a/src/internal/renameditem.hpp +++ b/src/internal/renameditem.hpp @@ -10,11 +10,12 @@ #ifndef RENAMEDITEM_HPP #define RENAMEDITEM_HPP -#include "bitinputarchive.hpp" #include "internal/genericinputitem.hpp" namespace bit7z { +class BitInputArchive; + class RenamedItem final : public GenericInputItem { public: explicit RenamedItem( const BitInputArchive& inputArchive, uint32_t index, const tstring& newPath ); diff --git a/src/internal/streamextractcallback.cpp b/src/internal/streamextractcallback.cpp index 9c8b1f85..aa9bdbba 100644 --- a/src/internal/streamextractcallback.cpp +++ b/src/internal/streamextractcallback.cpp @@ -12,6 +12,7 @@ #include "internal/streamextractcallback.hpp" +#include "bitinputarchive.hpp" #include "internal/cstdoutstream.hpp" #include "internal/util.hpp" diff --git a/src/internal/streamextractcallback.hpp b/src/internal/streamextractcallback.hpp index 374ec992..e3a40de0 100644 --- a/src/internal/streamextractcallback.hpp +++ b/src/internal/streamextractcallback.hpp @@ -16,6 +16,8 @@ namespace bit7z { +class BitInputArchive; + class StreamExtractCallback final : public ExtractCallback { public: StreamExtractCallback( const BitInputArchive& inputArchive, std::ostream& outputStream ); diff --git a/src/internal/updatecallback.hpp b/src/internal/updatecallback.hpp index 1b0a753e..f60b0a9a 100644 --- a/src/internal/updatecallback.hpp +++ b/src/internal/updatecallback.hpp @@ -10,7 +10,6 @@ #ifndef UPDATECALLBACK_HPP #define UPDATECALLBACK_HPP -#include "bitoutputarchive.hpp" #include "internal/callback.hpp" #include "internal/macros.hpp" @@ -20,6 +19,8 @@ namespace bit7z { +class BitOutputArchive; + class UpdateCallback final : public Callback, public IArchiveUpdateCallback2, public ICompressProgressInfo, diff --git a/tests/src/utils/filesystem.hpp b/tests/src/utils/filesystem.hpp index 0856aa89..74aa03e4 100644 --- a/tests/src/utils/filesystem.hpp +++ b/tests/src/utils/filesystem.hpp @@ -62,14 +62,14 @@ inline auto set_current_dir( const fs::path& dir ) -> bool { return !error; } -inline auto load_file( fs::path const& inFile ) -> std::vector< bit7z::byte_t > { +inline auto load_file( fs::path const& inFile ) -> buffer_t { fs::ifstream ifs{ inFile, fs::ifstream::binary }; if ( !ifs.is_open() ) { return {}; } noskipws( ifs ); //no skip spaces! auto size = fs::file_size( inFile ); - std::vector< bit7z::byte_t > result( size ); + buffer_t result( size ); // NOLINTNEXTLINE(*-pro-type-reinterpret-cast) ifs.read( reinterpret_cast( result.data() ), result.cend() - result.cbegin() ); //note: using basic_ifstream with istreambuf_iterator would be cleaner, but it is 10x slower.