bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitarchiveeditor.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 BITARCHIVEEDITOR_HPP
11#define BITARCHIVEEDITOR_HPP
12
13#include <unordered_map>
14
15#include "bitarchivewriter.hpp"
16
17namespace bit7z {
18
19using std::vector;
20
22
30class BIT7Z_MAYBE_UNUSED BitArchiveEditor final : public BitArchiveWriter {
31 public:
41 const tstring& inFile,
42 const BitInOutFormat& format,
43 const tstring& password = {} );
44
45 BitArchiveEditor( const BitArchiveEditor& ) = delete;
46
48
49 auto operator=( const BitArchiveEditor& ) -> BitArchiveEditor& = delete;
50
51 auto operator=( BitArchiveEditor&& ) -> BitArchiveEditor& = delete;
52
53 ~BitArchiveEditor() override;
54
62 void setUpdateMode( UpdateMode mode ) override;
63
70 void renameItem( uint32_t index, const tstring& newPath );
71
78 void renameItem( const tstring& oldPath, const tstring& newPath );
79
87 void updateItem( uint32_t index, const tstring& inFile );
88
96 void updateItem( uint32_t index, const std::vector< byte_t >& inBuffer );
97
105 void updateItem( uint32_t index, std::istream& inStream );
106
114 void updateItem( const tstring& itemPath, const tstring& inFile );
115
123 void updateItem( const tstring& itemPath, const std::vector< byte_t >& inBuffer );
124
132 void updateItem( const tstring& itemPath, istream& inStream );
133
139 void deleteItem( uint32_t index );
140
146 void deleteItem( const tstring& itemPath );
147
152
153 private:
154 EditedItems mEditedItems;
155
156 auto findItem( const tstring& itemPath ) -> uint32_t;
157
158 void checkIndex( uint32_t index );
159
160 auto itemProperty( InputIndex index, BitProperty property ) const -> BitPropVariant override;
161
162 auto itemStream( InputIndex index, ISequentialInStream** inStream ) const -> HRESULT override;
163
164 auto hasNewData( uint32_t index ) const noexcept -> bool override;
165
166 auto hasNewProperties( uint32_t index ) const noexcept -> bool override;
167};
168
169} // namespace bit7z
170
171#endif //BITARCHIVEEDITOR_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:56
The BitArchiveEditor class allows creating new file archives or updating old ones.
Definition bitarchiveeditor.hpp:30
void updateItem(const tstring &itemPath, istream &inStream)
Requests to update the content of the item at the specified path with the data from the given stream.
void deleteItem(uint32_t index)
Marks the item at the given index as deleted.
void applyChanges()
Applies the requested changes (i.e., rename/update/delete operations) to the input archive.
void renameItem(const tstring &oldPath, const tstring &newPath)
Requests to change the path of the item from oldPath to the newPath.
void setUpdateMode(UpdateMode mode) override
Sets how the editor performs the update of the items in the archive.
void updateItem(uint32_t index, const tstring &inFile)
Requests to update the content of the item at the specified index with the data from the given file.
void updateItem(const tstring &itemPath, const std::vector< byte_t > &inBuffer)
Requests to update the content of the item at the specified path with the data from the given buffer.
void deleteItem(const tstring &itemPath)
Marks the item at the given path (in the archive) as deleted.
void updateItem(uint32_t index, const std::vector< byte_t > &inBuffer)
Requests to update the content of the item at the specified index with the data from the given buffer...
void renameItem(uint32_t index, const tstring &newPath)
Requests to change the path of the item at the specified index with the given one.
void updateItem(const tstring &itemPath, const tstring &inFile)
Requests to update the content of the item at the specified path with the data from the given file.
void updateItem(uint32_t index, std::istream &inStream)
Requests to update the content of the item at the specified index with the data from the given stream...
BitArchiveEditor(const Bit7zLibrary &lib, const tstring &inFile, const BitInOutFormat &format, const tstring &password={})
Constructs a BitArchiveEditor object, reading the given archive file path.
The BitArchiveWriter class allows creating new archives or updating old ones with new items.
Definition bitarchivewriter.hpp:20
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:105
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
UpdateMode
Enumeration representing how an archive creator should deal when the output archive already exists.
Definition bitabstractarchivecreator.hpp:34
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:150