Skip to content

Commit

Permalink
Merge branch 'hotfix/v4.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyoz committed Dec 15, 2024
2 parents 003b7a0 + 1de83a6 commit 386e00a
Show file tree
Hide file tree
Showing 25 changed files with 699 additions and 150 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake_minimum_required( VERSION 3.14 )

project( bit7z
VERSION 4.0.8
VERSION 4.0.9
DESCRIPTION "A C++ static library offering a clean and simple interface to the 7-zip/p7zip shared libraries"
HOMEPAGE_URL "https://github.com/rikyoz/bit7z/" )
set( CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON" )
Expand Down
141 changes: 91 additions & 50 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ for:
- cd ..
- mkdir -p pkg/bit7z/
- mkdir -p pkg/bit7z/include/
- cp -r lib pkg/bit7z
- cp -r include pkg/bit7z/include/
- cp -r lib pkg/bit7z/
- cp -r include pkg/bit7z/
- cp README.md pkg/bit7z/
- cp LICENSE pkg/bit7z/
- echo $bit7z_version $compiler_tag > "pkg/bit7z/BUILD.txt"
Expand Down Expand Up @@ -198,7 +198,7 @@ deploy:
tag: $(APPVEYOR_REPO_TAG_NAME)
description: 'Binaries of Bit7z %bit7z_version%'
auth_token:
secure: 5b0wRmYrS2S5MEu+5rslOkBY//wJ+ShwhxNeOhxaAaMjTYRbSDqe4cme0CukKSgp
secure: aaQkoEIZv7oaBSZT2f/bST7NfLOdqKXitnhWmUqaW1T493Pr2/atcZWHIlExsLAx
artifact: /.*\.7z/
draft: true
prerelease: false
Expand Down
4 changes: 2 additions & 2 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Downloading the CPM.cmake package manager
set( CPM_DOWNLOAD_VERSION 0.38.6 )
set( CPM_DOWNLOAD_HASH 11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07 )
set( CPM_DOWNLOAD_VERSION 0.40.2 )
set( CPM_DOWNLOAD_HASH "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d" )
set( CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake" )
if( NOT ( EXISTS ${CPM_DOWNLOAD_LOCATION} ) )
message( STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}" )
Expand Down
69 changes: 66 additions & 3 deletions include/bit7z/bitarchivereader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,53 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
*
* @param lib the 7z library used.
* @param inArchive the path to the archive to be read.
* @param archiveStart whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the format of the input archive.
* @param password the password needed for opening the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
const tstring& inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveReader object, opening the input file archive.
*
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
* the format argument must be specified.
*
* @param lib the 7z library used.
* @param inArchive the path to the archive to be read.
* @param format the format of the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
const tstring& inArchive,
const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveReader object, opening the archive in the input buffer.
*
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
* the format argument must be specified.
*
* @param lib the 7z library used.
* @param inArchive the input buffer containing the archive to be read.
* @param archiveStart whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the format of the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
const buffer_t& inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
const tstring& password = {} );

Expand All @@ -55,13 +97,34 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
* @param lib the 7z library used.
* @param inArchive the input buffer containing the archive to be read.
* @param format the format of the input archive.
* @param password the password needed for opening the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
const std::vector< byte_t >& inArchive,
const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveReader object, opening the archive from the standard input stream.
*
* @note When bit7z is compiled using the `BIT7Z_AUTO_FORMAT` option, the format
* argument has the default value BitFormat::Auto (automatic format detection of the input archive).
* On the contrary, when `BIT7Z_AUTO_FORMAT` is not defined (i.e., no auto format detection available),
* the format argument must be specified.
*
* @param lib the 7z library used.
* @param inArchive the standard input stream of the archive to be read.
* @param archiveStart whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the format of the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
std::istream& inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveReader object, opening the archive from the standard input stream.
*
Expand All @@ -73,7 +136,7 @@ class BitArchiveReader final : public BitAbstractArchiveOpener, public BitInputA
* @param lib the 7z library used.
* @param inArchive the standard input stream of the archive to be read.
* @param format the format of the input archive.
* @param password the password needed for opening the input archive.
* @param password (optional) the password needed for opening the input archive.
*/
BitArchiveReader( const Bit7zLibrary& lib,
std::istream& inArchive,
Expand Down
48 changes: 48 additions & 0 deletions include/bit7z/bitarchivewriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,43 @@ class BitArchiveWriter : public BitAbstractArchiveCreator, public BitOutputArchi
*
* @param lib the 7z library to use.
* @param inArchive the path to an input archive file.
* @param startOffset whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the input/output archive format.
* @param password (optional) the password needed to read the input archive.
*/
BitArchiveWriter( const Bit7zLibrary& lib,
const tstring& inArchive,
ArchiveStartOffset startOffset,
const BitInOutFormat& format,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveWriter object, reading the given archive file path.
*
* @param lib the 7z library to use.
* @param inArchive the path to an input archive file.
* @param format the input/output archive format.
* @param password (optional) the password needed to read the input archive.
*/
BitArchiveWriter( const Bit7zLibrary& lib,
const tstring& inArchive,
const BitInOutFormat& format,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveWriter object, reading the archive in the given buffer.
*
* @param lib the 7z library to use.
* @param inArchive the buffer containing the input archive.
* @param startOffset whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the input/output archive format.
* @param password (optional) the password needed to read the input archive.
*/
BitArchiveWriter( const Bit7zLibrary& lib,
const buffer_t& inArchive,
ArchiveStartOffset startOffset,
const BitInOutFormat& format,
const tstring& password = {} );

Expand All @@ -53,6 +85,22 @@ class BitArchiveWriter : public BitAbstractArchiveCreator, public BitOutputArchi
const BitInOutFormat& format,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveWriter object, reading the archive from the given standard input stream.
*
* @param lib the 7z library to use.
* @param inArchive the standard stream of the input archive.
* @param startOffset whether to search for the archive's start throughout the entire file
* or only at the beginning.
* @param format the input/output archive format.
* @param password (optional) the password needed to read the input archive.
*/
BitArchiveWriter( const Bit7zLibrary& lib,
std::istream& inArchive,
ArchiveStartOffset startOffset,
const BitInOutFormat& format,
const tstring& password = {} );

/**
* @brief Constructs a BitArchiveWriter object, reading the archive from the given standard input stream.
*
Expand Down
79 changes: 62 additions & 17 deletions include/bit7z/bitinputarchive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace bit7z {

using std::vector;

enum struct ArchiveStartOffset : std::uint8_t {
None, ///< Don't specify an archive start offset. For some formats, like Zip archives,
///< this means that the whole input file will be searched for the archive's start.
FileStart ///< Check only the file start for the archive's start.
};

/**
* @brief The BitInputArchive class, given a handler object, allows reading/extracting the content of archives.
*/
Expand All @@ -33,38 +39,54 @@ class BitInputArchive {
/**
* @brief Constructs a BitInputArchive object, opening the input file archive.
*
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inFile the path to the input archive file
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inFile the path to the input archive file
* @param startOffset (optional) specifies whether to search for the archive's start throughout the
* entire file or only at the beginning. The default behavior is to search at the beginning.
*/
BitInputArchive( const BitAbstractArchiveHandler& handler, const tstring& inFile );
BitInputArchive( const BitAbstractArchiveHandler& handler,
const tstring& inFile,
ArchiveStartOffset startOffset = ArchiveStartOffset::None );

/**
* @brief Constructs a BitInputArchive object, opening the input file archive.
*
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param arcPath the path to the input archive file
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param arcPath the path to the input archive file
* @param startOffset (optional) whether to search for the archive's start throughout the entire file
* or only at the beginning. The default behavior is to search at the beginning.
*/
BitInputArchive( const BitAbstractArchiveHandler& handler, const fs::path& arcPath );
BitInputArchive( const BitAbstractArchiveHandler& handler,
const fs::path& arcPath,
ArchiveStartOffset startOffset = ArchiveStartOffset::None );

/**
* @brief Constructs a BitInputArchive object, opening the archive given in the input buffer.
*
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inBuffer the buffer containing the input archive
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inBuffer the buffer containing the input archive
* @param startOffset (optional) whether to search for the archive's start throughout the entire file
* or only at the beginning. The default behavior is to search at the beginning.
*/
BitInputArchive( const BitAbstractArchiveHandler& handler, const std::vector< byte_t >& inBuffer );
BitInputArchive( const BitAbstractArchiveHandler& handler,
const buffer_t& inBuffer,
ArchiveStartOffset startOffset = ArchiveStartOffset::None );

/**
* @brief Constructs a BitInputArchive object, opening the archive by reading the given input stream.
*
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inStream the standard input stream of the input archive
* @param handler the reference to the BitAbstractArchiveHandler object containing all the settings to
* be used for reading the input archive
* @param inStream the standard input stream of the input archive
* @param startOffset (optional) whether to search for the archive's start throughout the entire file
* or only at the beginning. The default behavior is to search at the beginning.
*/
BitInputArchive( const BitAbstractArchiveHandler& handler, std::istream& inStream );
BitInputArchive( const BitAbstractArchiveHandler& handler,
std::istream& inStream,
ArchiveStartOffset startOffset = ArchiveStartOffset::None );

BitInputArchive( const BitInputArchive& ) = delete;

Expand Down Expand Up @@ -130,6 +152,27 @@ class BitInputArchive {
*/
BIT7Z_NODISCARD auto handler() const noexcept -> const BitAbstractArchiveHandler&;

/**
* @brief Use the given format property to read the archive.
*
* @param name the name of the property.
* @param property the property value.
*/
void useFormatProperty( const wchar_t* name, const BitPropVariant& property ) const;

/**
* @brief Use the given format property to read the archive.
*
* @tparam T the type of the property.
* @param name the name of the property.
* @param value the property value.
*/
template< typename T,
typename = typename std::enable_if< is_explicitly_convertible< T, BitPropVariant >::value >::type >
void useFormatProperty( const wchar_t* name, T&& value ) const { // NOLINT(*-avoid-c-arrays)
useFormatProperty( name, BitPropVariant{ std::forward< T >( value ) } );
}

BIT7Z_DEPRECATED_MSG("Since v4.0; please, use the extractTo method.")
inline void extract( const tstring& outDir, const std::vector< uint32_t >& indices = {} ) const {
extractTo( outDir, indices );
Expand Down Expand Up @@ -275,7 +318,8 @@ class BitInputArchive {
const BitAbstractArchiveHandler& mArchiveHandler;
tstring mArchivePath;

auto openArchiveStream( const fs::path& name, IInStream* inStream ) -> IInArchive*;
BIT7Z_NODISCARD
auto openArchiveStream( const fs::path& name, IInStream* inStream, ArchiveStartOffset startOffset ) -> IInArchive*;

public:
/**
Expand Down Expand Up @@ -397,6 +441,7 @@ class BitInputArchive {
* @return the item at the given index within the archive.
*/
BIT7Z_NODISCARD auto itemAt( uint32_t index ) const -> BitArchiveItemOffset;

};

} // namespace bit7z
Expand Down
Loading

0 comments on commit 386e00a

Please sign in to comment.