summaryrefslogtreecommitdiffstats
path: root/ftparchive/multicompress.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:14:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 06:14:41 +0000
commit549a391d6438e828001eeeaf235b080c054a7bf3 (patch)
tree1bb6b1ea5987fa167a1d13abe82209cc882dd94b /ftparchive/multicompress.h
parentInitial commit. (diff)
downloadapt-549a391d6438e828001eeeaf235b080c054a7bf3.tar.xz
apt-549a391d6438e828001eeeaf235b080c054a7bf3.zip
Adding upstream version 2.2.4.upstream/2.2.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ftparchive/multicompress.h62
1 files changed, 62 insertions, 0 deletions
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 <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/fileutl.h>
+
+#include <string>
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h>
+
+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