]> git.saurik.com Git - apt.git/blob - ftparchive/multicompress.h
l10n: vi.po (624t): Update translation
[apt.git] / ftparchive / multicompress.h
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
19 #include <apt-pkg/fileutl.h>
20 #include <apt-pkg/aptconfiguration.h>
21
22 #include <string>
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <time.h>
26
27 class MultiCompress
28 {
29 // An output file
30 struct Files
31 {
32 std::string Output;
33 APT::Configuration::Compressor CompressProg;
34 Files *Next;
35 FileFd TmpFile;
36 pid_t CompressProc;
37 time_t OldMTime;
38 };
39
40 Files *Outputs;
41 pid_t Outputter;
42 mode_t Permissions;
43
44 bool Child(int const &Fd);
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
54 bool Finalize(unsigned long long &OutSize);
55 bool OpenOld(FileFd &Fd);
56 static bool GetStat(std::string const &Output,std::string const &Compress,struct stat &St);
57
58 MultiCompress(std::string const &Output,std::string const &Compress,
59 mode_t const &Permissions, bool const &Write = true);
60 ~MultiCompress();
61 };
62
63 #endif