]> git.saurik.com Git - apt.git/blame - ftparchive/multicompress.h
add APT::FTPArchive::AlwaysStat to disable the too aggressive
[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
b3d44315 56 bool OpenCompress(const CompType *Prog,pid_t &Pid,int FileFd,
b2e465d6
AL
57 int &OutFd,bool Comp);
58 bool Child(int Fd);
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);
b2e465d6
AL
71 static bool GetStat(string Output,string Compress,struct stat &St);
72
73 MultiCompress(string Output,string Compress,mode_t Permissions,
74 bool Write = true);
75 ~MultiCompress();
76};
77
78#endif