From 636c7dc17286d93d788c741d15fd756aeda066d5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 20:07:13 +0200 Subject: Adding upstream version 1.8.2.3. Signed-off-by: Daniel Baumann --- ftparchive/multicompress.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ftparchive/multicompress.h (limited to 'ftparchive/multicompress.h') diff --git a/ftparchive/multicompress.h b/ftparchive/multicompress.h new file mode 100644 index 0000000..c237269 --- /dev/null +++ b/ftparchive/multicompress.h @@ -0,0 +1,62 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ###################################################################### + + MultiCompressor + + Multiple output class. Takes a single FILE* and writes it simultaneously + to many compressed files. Then checks if the resulting output is + different from any previous output and overwrites the old files. Care is + taken to ensure that the new files are not generally readable while they + are being written. + + ##################################################################### */ + /*}}}*/ +#ifndef MULTICOMPRESS_H +#define MULTICOMPRESS_H + +#include +#include + +#include +#include +#include +#include + +class MultiCompress +{ + // An output file + struct Files + { + std::string Output; + APT::Configuration::Compressor CompressProg; + Files *Next; + FileFd TmpFile; + pid_t CompressProc; + time_t OldMTime; + }; + + Files *Outputs; + pid_t Outputter; + mode_t Permissions; + + bool Child(int const &Fd); + bool Start(); + bool Die(); + + public: + + // The FD to write to for compression. + FileFd Input; + unsigned long UpdateMTime; + + bool Finalize(unsigned long long &OutSize); + bool OpenOld(FileFd &Fd); + static bool GetStat(std::string const &Output,std::string const &Compress,struct stat &St); + + MultiCompress(std::string const &Output,std::string const &Compress, + mode_t const &Permissions, bool const &Write = true); + ~MultiCompress(); +}; + +#endif -- cgit v1.2.3