summaryrefslogtreecommitdiff
path: root/ftparchive/multicompress.h
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:56:32 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:56:32 +0000
commitb2e465d6d32d2dc884f58b94acb7e35f671a87fe (patch)
tree5928383b9bde7b0ba9812e6526ad746466e558f7 /ftparchive/multicompress.h
parent00b47c98ca4a4349686a082eba6d77decbb03a4d (diff)
Join with aliencode
Author: jgg Date: 2001-02-20 07:03:16 GMT Join with aliencode
Diffstat (limited to 'ftparchive/multicompress.h')
-rw-r--r--ftparchive/multicompress.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/ftparchive/multicompress.h b/ftparchive/multicompress.h
new file mode 100644
index 000000000..212dec63d
--- /dev/null
+++ b/ftparchive/multicompress.h
@@ -0,0 +1,80 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: multicompress.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
+/* ######################################################################
+
+ 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
+
+#ifdef __GNUG__
+#pragma interface "multicompress.h"
+#endif
+
+#include <string>
+#include <apt-pkg/fileutl.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+class MultiCompress
+{
+ // Enumeration of all supported compressors
+ struct CompType
+ {
+ const char *Name;
+ const char *Extension;
+ const char *Binary;
+ const char *CompArgs;
+ const char *UnCompArgs;
+ unsigned char Cost;
+ };
+
+ // An output file
+ struct Files
+ {
+ string Output;
+ const CompType *CompressProg;
+ Files *Next;
+ FileFd TmpFile;
+ pid_t CompressProc;
+ time_t OldMTime;
+ int Fd;
+ };
+
+ Files *Outputs;
+ pid_t Outputter;
+ mode_t Permissions;
+ static const CompType Compressors[];
+
+ bool OpenCompress(const CompType *Prog,int &Pid,int FileFd,
+ int &OutFd,bool Comp);
+ bool Child(int Fd);
+ bool Start();
+ bool Die();
+
+ public:
+
+ // The FD to write to for compression.
+ FILE *Input;
+ unsigned long UpdateMTime;
+
+ bool Finalize(unsigned long &OutSize);
+ bool OpenOld(int &Fd,int &Proc);
+ bool CloseOld(int Fd,int Proc);
+ static bool GetStat(string Output,string Compress,struct stat &St);
+
+ MultiCompress(string Output,string Compress,mode_t Permissions,
+ bool Write = true);
+ ~MultiCompress();
+};
+
+#endif