]>
Commit | Line | Data |
---|---|---|
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 | ||
13500573 | 19 | |
b2e465d6 AL |
20 | |
21 | #include <string> | |
22 | #include <apt-pkg/fileutl.h> | |
03bef784 | 23 | #include <apt-pkg/aptconfiguration.h> |
b2e465d6 AL |
24 | #include <stdio.h> |
25 | #include <sys/types.h> | |
26 | ||
27 | class MultiCompress | |
28 | { | |
b2e465d6 AL |
29 | // An output file |
30 | struct Files | |
31 | { | |
32 | string Output; | |
03bef784 DK |
33 | APT::Configuration::Compressor CompressProg; |
34 | Files *Next; | |
b2e465d6 AL |
35 | FileFd TmpFile; |
36 | pid_t CompressProc; | |
37 | time_t OldMTime; | |
38 | int Fd; | |
39 | }; | |
40 | ||
41 | Files *Outputs; | |
42 | pid_t Outputter; | |
43 | mode_t Permissions; | |
b2e465d6 | 44 | |
03bef784 DK |
45 | bool OpenCompress(APT::Configuration::Compressor const &Prog, |
46 | pid_t &Pid,int const &FileFd, int &OutFd,bool const &Comp); | |
9209ec47 | 47 | bool Child(int const &Fd); |
b2e465d6 AL |
48 | bool Start(); |
49 | bool Die(); | |
50 | ||
51 | public: | |
52 | ||
53 | // The FD to write to for compression. | |
54 | FILE *Input; | |
55 | unsigned long UpdateMTime; | |
56 | ||
57 | bool Finalize(unsigned long &OutSize); | |
b3d44315 MV |
58 | bool OpenOld(int &Fd,pid_t &Proc); |
59 | bool CloseOld(int Fd,pid_t Proc); | |
9209ec47 | 60 | static bool GetStat(string const &Output,string const &Compress,struct stat &St); |
b2e465d6 | 61 | |
9209ec47 DK |
62 | MultiCompress(string const &Output,string const &Compress, |
63 | mode_t const &Permissions, bool const &Write = true); | |
b2e465d6 AL |
64 | ~MultiCompress(); |
65 | }; | |
66 | ||
67 | #endif |