TarWriter.h
1/* Copyright (C) 2008 Marc Boris Duerner
2 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
3*/
4
5#ifndef PT_SYSTEM_TAR_WRITER_H
6#define PT_SYSTEM_TAR_WRITER_H
7
8#include <Pt/System/Api.h>
9#include <Pt/System/TarEntry.h>
10
11#include <ostream>
12#include <cstddef>
13
14namespace Pt {
15
16namespace System {
17
87class PT_SYSTEM_API TarWriter
88{
89 public:
93
96 explicit TarWriter(std::ostream& os);
97
101
108 void attach(std::ostream& os);
109
112 void detach();
113
119 void reset();
120
132 void addFile(const TarEntry& entry, const char* data, std::size_t size);
133
140 void addDirectory(const TarEntry& entry);
141
149 void addSymlink(const TarEntry& entry);
150
158 void addHardlink(const TarEntry& entry);
159
171 void beginFile(const TarEntry& entry);
172
183 void writeFile(const char* data, std::size_t size);
184
193 void endFile();
194
202 void finish();
203
204 private:
205 TarWriter(const TarWriter&);
206
207 TarWriter& operator=(const TarWriter&);
208
209 private:
210 class TarWriterImpl* _impl;
211};
212
213} // namespace System
214
215} // namespace Pt
216
217#endif // PT_SYSTEM_TAR_WRITER_H
One entry in a tar archive.
Definition TarEntry.h:72
TarWriter()
Creates a writer with no stream attached.
void addHardlink(const TarEntry &entry)
Writes a hard link.
void addDirectory(const TarEntry &entry)
Writes a directory member.
void writeFile(const char *data, std::size_t size)
Writes the next content chunk of the open streamed file.
~TarWriter()
Destructor.
void finish()
Writes the end-of-archive marker.
void attach(std::ostream &os)
Attaches os as the destination.
void beginFile(const TarEntry &entry)
Writes the header of a file whose content follows in chunks.
void endFile()
Finishes the streamed file opened by beginFile().
TarWriter(std::ostream &os)
Creates a writer that appends to os.
void addSymlink(const TarEntry &entry)
Writes a symbolic link.
void detach()
Detaches the current destination.
void reset()
Detaches the destination and clears the writer state.
void addFile(const TarEntry &entry, const char *data, std::size_t size)
Writes a regular file from a memory buffer.
System programming
Definition Connection.h:26
Core module.
Definition Allocator.h:33