]> git.saurik.com Git - apt.git/blame - ftparchive/multicompress.h
evaluate Acquire::Languages= before LANG= (Closes: #602573)
[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
13500573 19
b2e465d6
AL
20
21#include <string>
22#include <apt-pkg/fileutl.h>
23#include <stdio.h>
24#include <sys/types.h>
25
26class MultiCompress
27{
28 // Enumeration of all supported compressors
29 struct CompType
30 {
31 const char *Name;
32 const char *Extension;
33 const char *Binary;
34 const char *CompArgs;
35 const char *UnCompArgs;
36 unsigned char Cost;
37 };
38
39 // An output file
40 struct Files
41 {
42 string Output;
43 const CompType *CompressProg;
44 Files *Next;
45 FileFd TmpFile;
46 pid_t CompressProc;
47 time_t OldMTime;
48 int Fd;
49 };
50
51 Files *Outputs;
52 pid_t Outputter;
53 mode_t Permissions;
54 static const CompType Compressors[];
55
9209ec47
DK
56 bool OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
57 int &OutFd,bool const &Comp);
58 bool Child(int const &Fd);
b2e465d6
AL
59 bool Start();
60 bool Die();
61
62 public:
63
64 // The FD to write to for compression.
65 FILE *Input;
66 unsigned long UpdateMTime;
67
68 bool Finalize(unsigned long &OutSize);
b3d44315
MV
69 bool OpenOld(int &Fd,pid_t &Proc);
70 bool CloseOld(int Fd,pid_t Proc);
9209ec47 71 static bool GetStat(string const &Output,string const &Compress,struct stat &St);
b2e465d6 72
9209ec47
DK
73 MultiCompress(string const &Output,string const &Compress,
74 mode_t const &Permissions, bool const &Write = true);
b2e465d6
AL
75 ~MultiCompress();
76};
77
78#endif