bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitarchivereader.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) 2014-2023 Riccardo Ostani - All Rights Reserved.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef BITARCHIVEREADER_HPP
11#define BITARCHIVEREADER_HPP
12
13#include "bitabstractarchiveopener.hpp"
14#include "bitarchiveiteminfo.hpp"
15#include "bitexception.hpp"
16#include "bitinputarchive.hpp"
17
18struct IInArchive;
19struct IOutArchive;
20struct IArchiveExtractCallback;
21
22namespace bit7z {
23
28 public:
43 const tstring& inArchive,
44 const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
45 const tstring& password = {} );
46
61 const std::vector< byte_t >& inArchive,
62 const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
63 const tstring& password = {} );
64
79 std::istream& inArchive,
80 const BitInFormat& format BIT7Z_DEFAULT_FORMAT,
81 const tstring& password = {} );
82
83 BitArchiveReader( const BitArchiveReader& ) = delete;
84
86
87 auto operator=( const BitArchiveReader& ) -> BitArchiveReader& = delete;
88
89 auto operator=( BitArchiveReader&& ) -> BitArchiveReader& = delete;
90
96 ~BitArchiveReader() override = default;
97
101 BIT7Z_NODISCARD auto archiveProperties() const -> map< BitProperty, BitPropVariant >;
102
106 BIT7Z_NODISCARD auto items() const -> vector< BitArchiveItemInfo >;
107
111 BIT7Z_NODISCARD auto foldersCount() const -> uint32_t;
112
116 BIT7Z_NODISCARD auto filesCount() const -> uint32_t;
117
121 BIT7Z_NODISCARD auto size() const -> uint64_t;
122
126 BIT7Z_NODISCARD auto packSize() const -> uint64_t;
127
131 BIT7Z_NODISCARD auto hasEncryptedItems() const -> bool;
132
136 BIT7Z_NODISCARD auto isEncrypted() const -> bool;
137
141 BIT7Z_NODISCARD auto volumesCount() const -> uint32_t;
142
146 BIT7Z_NODISCARD auto isMultiVolume() const -> bool;
147
151 BIT7Z_NODISCARD auto isSolid() const -> bool;
152
164 template< typename T >
165 BIT7Z_NODISCARD
166 static auto isHeaderEncrypted( const Bit7zLibrary& lib,
167 T&& inArchive,
168 const BitInFormat& format BIT7Z_DEFAULT_FORMAT ) -> bool {
169 try {
170 const BitArchiveReader reader{ lib, std::forward< T >( inArchive ), format };
171 return false;
172 } catch ( const BitException& ex ) {
173 return isOpenEncryptedError( ex.code() );
174 }
175 }
176
193 template< typename T >
194 BIT7Z_NODISCARD
195 static auto isEncrypted( const Bit7zLibrary& lib,
196 T&& inArchive,
197 const BitInFormat& format BIT7Z_DEFAULT_FORMAT ) -> bool {
198 try {
199 const BitArchiveReader reader{ lib, std::forward< T >( inArchive ), format };
200 return reader.isEncrypted();
201 } catch ( const BitException& ex ) {
202 return isOpenEncryptedError( ex.code() );
203 }
204 }
205
206 private:
207 static auto isOpenEncryptedError( std::error_code error ) -> bool;
208};
209
210using BitArchiveInfo BIT7Z_MAYBE_UNUSED BIT7Z_DEPRECATED_MSG("Since v4.0; please use BitArchiveReader.") = BitArchiveReader;
211
212} // namespace bit7z
213
214#endif // BITARCHIVEREADER_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:56
auto password() const -> tstring
The BitAbstractArchiveOpener abstract class represents a generic archive opener.
Definition bitabstractarchiveopener.hpp:26
auto format() const noexcept -> const BitInFormat &override
The BitArchiveItemInfo class represents an archived item and that stores all its properties for later...
Definition bitarchiveiteminfo.hpp:25
The BitArchiveReader class allows reading metadata of archives, as well as extracting them.
Definition bitarchivereader.hpp:27
auto items() const -> vector< BitArchiveItemInfo >
static auto isHeaderEncrypted(const Bit7zLibrary &lib, T &&inArchive, const BitInFormat &format=BitFormat::Auto) -> bool
Checks if the given archive is header-encrypted or not.
Definition bitarchivereader.hpp:166
auto isMultiVolume() const -> bool
auto foldersCount() const -> uint32_t
auto isEncrypted() const -> bool
auto volumesCount() const -> uint32_t
~BitArchiveReader() override=default
BitArchiveReader destructor.
auto size() const -> uint64_t
BitArchiveReader(const Bit7zLibrary &lib, const tstring &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
Constructs a BitArchiveReader object, opening the input file archive.
auto hasEncryptedItems() const -> bool
auto packSize() const -> uint64_t
auto isSolid() const -> bool
BitArchiveReader(const Bit7zLibrary &lib, const std::vector< byte_t > &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
Constructs a BitArchiveReader object, opening the archive in the input buffer.
static auto isEncrypted(const Bit7zLibrary &lib, T &&inArchive, const BitInFormat &format=BitFormat::Auto) -> bool
Checks if the given archive contains only encrypted items.
Definition bitarchivereader.hpp:195
BitArchiveReader(const Bit7zLibrary &lib, std::istream &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
Constructs a BitArchiveReader object, opening the archive from the standard input stream.
auto filesCount() const -> uint32_t
auto archiveProperties() const -> map< BitProperty, BitPropVariant >
The BitException class represents a generic exception thrown from the bit7z classes.
Definition bitexception.hpp:32
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:58
The BitInputArchive class, given a handler object, allows reading/extracting the content of archives.
Definition bitinputarchive.hpp:31
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
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:150