bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitabstractarchivecreator.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) 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 BITABSTRACTARCHIVECREATOR_HPP
11#define BITABSTRACTARCHIVECREATOR_HPP
12
13#include "bit7zlibrary.hpp"
14#include "bitabstractarchivehandler.hpp"
15#include "bitcompressionlevel.hpp"
16#include "bitcompressionmethod.hpp"
17#include "bitdefines.hpp"
18#include "bitformat.hpp"
19#include "bitinputarchive.hpp"
20#include "bitpropvariant.hpp"
21#include "bittypes.hpp"
22
23#include <cstddef>
24#include <cstdint>
25#include <map>
26#include <string>
27#include <type_traits>
28
29struct IOutStream;
30struct ISequentialOutStream;
31
32namespace bit7z {
33
34class ArchiveProperties;
35
39enum struct UpdateMode : std::uint8_t {
43 BIT7Z_DEPRECATED_ENUMERATOR( Overwrite, Update, "Since v4.0. Please use the UpdateMode::Update enumerator." )
44};
45
53
57class BitAbstractArchiveCreator : public BitAbstractArchiveHandler {
58 public:
59 BitAbstractArchiveCreator( const BitAbstractArchiveCreator& ) = delete;
60
61 BitAbstractArchiveCreator( BitAbstractArchiveCreator&& ) = delete;
62
63 auto operator=( const BitAbstractArchiveCreator& ) -> BitAbstractArchiveCreator& = delete;
64
65 auto operator=( BitAbstractArchiveCreator&& ) -> BitAbstractArchiveCreator& = delete;
66
67 ~BitAbstractArchiveCreator() override = default;
68
72 BIT7Z_NODISCARD auto format() const noexcept -> const BitInFormat& override;
73
77 BIT7Z_NODISCARD auto compressionFormat() const noexcept -> const BitInOutFormat&;
78
82 BIT7Z_NODISCARD auto cryptHeaders() const noexcept -> bool;
83
87 BIT7Z_NODISCARD auto compressionLevel() const noexcept -> BitCompressionLevel;
88
92 BIT7Z_NODISCARD auto compressionMethod() const noexcept -> BitCompressionMethod;
93
97 BIT7Z_NODISCARD auto dictionarySize() const noexcept -> std::uint32_t;
98
102 BIT7Z_NODISCARD auto wordSize() const noexcept -> std::uint32_t;
103
107 BIT7Z_NODISCARD auto solidMode() const noexcept -> bool;
108
112 BIT7Z_NODISCARD auto updateMode() const noexcept -> UpdateMode;
113
118 BIT7Z_NODISCARD auto volumeSize() const noexcept -> std::uint64_t;
119
124 BIT7Z_NODISCARD auto threadsCount() const noexcept -> std::uint32_t;
125
129 BIT7Z_NODISCARD auto storeSymbolicLinks() const noexcept -> bool;
130
134 BIT7Z_NODISCARD auto storeLastWriteTime() const noexcept -> bool;
135
139 BIT7Z_NODISCARD auto storeCreationTime() const noexcept -> bool;
140
144 BIT7Z_NODISCARD auto storeLastAccessTime() const noexcept -> bool;
145
149 BIT7Z_NODISCARD auto storeOpenFiles() const noexcept -> bool;
150
168 void setPassword( const tstring& password ) override;
169
193
219 BIT7Z_DEPRECATED_MSG( "Since v4.1. Please use the setPassword overload taking an EncryptionScope enumerator." )
221
228
235
241 void setDictionarySize( std::uint32_t dictionarySize );
242
248 void setWordSize( std::uint32_t wordSize );
249
258 void setSolidMode( bool solidMode ) noexcept;
259
268 virtual void setUpdateMode( UpdateMode mode );
269
280 BIT7Z_DEPRECATED_MSG( "Since v4.0. Please use the overloaded function that takes an UpdateMode enumerator." )
281 void setUpdateMode( bool canUpdate );
282
290 void setVolumeSize( std::uint64_t volumeSize ) noexcept;
291
297 void setThreadsCount( std::uint32_t threadsCount ) noexcept;
298
304 void setStoreSymbolicLinks( bool storeSymlinks ) noexcept;
305
314
321
328
342 void setStoreOpenFiles( bool storeOpenFiles ) noexcept;
343
353 template< std::size_t N, typename T, typename = typename std::enable_if< std::is_integral< T >::value >::type >
354 void setFormatProperty( const wchar_t (&name)[ N ], T value ) noexcept { // NOLINT(*-avoid-c-arrays)
355 mExtraProperties[ name ] = value;
356 }
357
370 template< std::size_t N, typename T, typename = typename std::enable_if< !std::is_integral< T >::value >::type >
371 void setFormatProperty( const wchar_t (&name)[ N ], const T& value ) noexcept { // NOLINT(*-avoid-c-arrays)
372 mExtraProperties[ name ] = value;
373 }
374
375 protected:
377 const Bit7zLibrary& lib,
378 const BitInOutFormat& format,
379 tstring password = {},
381 );
382
383 BIT7Z_NODISCARD auto archiveProperties() const -> ArchiveProperties;
384
385 friend class BitOutputArchive;
386
387 private:
388 const BitInOutFormat& mFormat;
389
390 UpdateMode mUpdateMode;
391 BitCompressionLevel mCompressionLevel;
392 BitCompressionMethod mCompressionMethod;
393 std::uint32_t mDictionarySize;
394 std::uint32_t mWordSize;
395 bool mCryptHeaders;
396 bool mSolidMode;
397 std::uint64_t mVolumeSize;
398 std::uint32_t mThreadsCount;
399 bool mStoreSymbolicLinks;
400 bool mStoreOpenFiles;
401 std::map< std::wstring, BitPropVariant > mExtraProperties;
402};
403
404} // namespace bit7z
405
406#endif // BITABSTRACTARCHIVECREATOR_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:55
Abstract class representing a generic archive creator.
Definition bitabstractarchivecreator.hpp:57
void setPassword(const tstring &password) override
Sets up a password for the output archives.
void setCompressionMethod(BitCompressionMethod method)
Sets the compression method to be used when creating/updating an archive.
void setFormatProperty(const wchar_t(&name)[N], const T &value) noexcept
Sets a property for the output archive format as described by the 7-zip documentation (e....
Definition bitabstractarchivecreator.hpp:371
auto storeCreationTime() const noexcept -> bool
auto threadsCount() const noexcept -> std::uint32_t
auto compressionFormat() const noexcept -> const BitInOutFormat &
void setWordSize(std::uint32_t wordSize)
Sets the word size to be used when creating/updating an archive.
auto dictionarySize() const noexcept -> std::uint32_t
auto compressionLevel() const noexcept -> BitCompressionLevel
void setSolidMode(bool solidMode) noexcept
Sets whether to use solid compression or not.
auto cryptHeaders() const noexcept -> bool
auto solidMode() const noexcept -> bool
void setStoreLastAccessTime(bool storeLastAccessTime) noexcept
Sets whether the creator will store last access timestamps of items.
auto wordSize() const noexcept -> std::uint32_t
void setStoreOpenFiles(bool storeOpenFiles) noexcept
Sets whether the creator will attempt to compress files that are locked by other processes.
auto storeOpenFiles() const noexcept -> bool
void setThreadsCount(std::uint32_t threadsCount) noexcept
Sets the number of threads to be used when creating/updating an archive.
void setStoreLastWriteTime(bool storeLastWriteTime) noexcept
Sets whether the creator will store last write timestamps of items.
auto format() const noexcept -> const BitInFormat &override
void setStoreSymbolicLinks(bool storeSymlinks) noexcept
Sets whether the creator will store symbolic links as links in the output archive.
auto storeSymbolicLinks() const noexcept -> bool
virtual void setUpdateMode(UpdateMode mode)
Sets whether and how the creator can update existing archives or not.
auto volumeSize() const noexcept -> std::uint64_t
void setCompressionLevel(BitCompressionLevel level) noexcept
Sets the compression level to be used when creating/updating an archive.
void setDictionarySize(std::uint32_t dictionarySize)
Sets the dictionary size to be used when creating/updating an archive.
auto compressionMethod() const noexcept -> BitCompressionMethod
auto storeLastAccessTime() const noexcept -> bool
void setVolumeSize(std::uint64_t volumeSize) noexcept
Sets the volumeSize (in bytes) of the output archive volumes.
auto storeLastWriteTime() const noexcept -> bool
void setFormatProperty(const wchar_t(&name)[N], T value) noexcept
Sets a property for the output archive format as described by the 7-zip documentation (e....
Definition bitabstractarchivecreator.hpp:354
auto updateMode() const noexcept -> UpdateMode
void setStoreCreationTime(bool storeCreationTime) noexcept
Sets whether the creator will store creation timestamps of items.
auto password() const -> const tstring &
virtual auto format() const noexcept -> const BitInFormat &=0
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:68
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:115
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
UpdateMode
Enumeration representing how an archive creator should deal when the output archive already exists.
Definition bitabstractarchivecreator.hpp:39
@ Update
New items whose path already exists in the archive will overwrite the old ones, other will be appende...
Definition bitabstractarchivecreator.hpp:42
@ Append
The creator will append the new items to the existing archive.
Definition bitabstractarchivecreator.hpp:41
@ None
The creator will throw an exception (unless the OverwriteMode is not None).
Definition bitabstractarchivecreator.hpp:40
@ Overwrite
Definition bitabstractarchivecreator.hpp:43
BitCompressionLevel
The BitCompressionLevel enum represents the compression level used by 7z when creating archives.
Definition bitcompressionlevel.hpp:21
EncryptionScope
The EncryptionScope enum represents the scope of encryption applied when setting a password on an arc...
Definition bitabstractarchivecreator.hpp:49
@ DataOnly
Only the archive's file data is encrypted.
Definition bitabstractarchivecreator.hpp:50
@ DataAndHeaders
Both the archive's file data and headers are encrypted (valid only for the 7z format).
Definition bitabstractarchivecreator.hpp:51
std::basic_string< tchar > tstring
Definition bittypes.hpp:104
BitCompressionMethod
The BitCompressionMethod enum represents the compression methods used by 7z when creating archives.
Definition bitcompressionmethod.hpp:20