Allow the FileFd to use an external Compressor to uncompress a given file
[ntk/apt.git] / ftparchive / multicompress.h
CommitLineData
b2e465d6
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: multicompress.h,v 1.2 2001/02/20 07:03:18 jgg Exp $
4/* ######################################################################
5
6 MultiCompressor
7
8 Multiple output class. Takes a single FILE* and writes it simultaneously
9 to many compressed files. Then checks if the resulting output is
10 different from any previous output and overwrites the old files. Care is
11 taken to ensure that the new files are not generally readable while they
12 are being written.
13
14 ##################################################################### */
15 /*}}}*/
16#ifndef MULTICOMPRESS_H
17#define MULTICOMPRESS_H
18
b2e465d6 19#include <apt-pkg/fileutl.h>
03bef784 20#include <apt-pkg/aptconfiguration.h>
472ff00e
DK
21
22#include <string>
b2e465d6
AL
23#include <stdio.h>
24#include <sys/types.h>
25
26class MultiCompress
27{
b2e465d6
AL
28 // An output file
29 struct Files
30 {
8f3ba4e8 31 std::string Output;
03bef784
DK
32 APT::Configuration::Compressor CompressProg;
33 Files *Next;
b2e465d6
AL
34 FileFd TmpFile;
35 pid_t CompressProc;
36 time_t OldMTime;
37 int Fd;
38 };
39
40 Files *Outputs;
41 pid_t Outputter;
42 mode_t Permissions;
b2e465d6 43
9209ec47 44 bool Child(int const &Fd);
b2e465d6
AL
45 bool Start();
46 bool Die();
47
48 public:
49
50 // The FD to write to for compression.
51 FILE *Input;
52 unsigned long UpdateMTime;
53
650faab0 54 bool Finalize(unsigned long long &OutSize);
b3d44315
MV
55 bool OpenOld(int &Fd,pid_t &Proc);
56 bool CloseOld(int Fd,pid_t Proc);
8f3ba4e8 57 static bool GetStat(std::string const &Output,std::string const &Compress,struct stat &St);
b2e465d6 58
8f3ba4e8 59 MultiCompress(std::string const &Output,std::string const &Compress,
9209ec47 60 mode_t const &Permissions, bool const &Write = true);
b2e465d6
AL
61 ~MultiCompress();
62};
63
64#endif