]>
Commit | Line | Data |
---|---|---|
30c8107e DK |
1 | #ifndef APT_APTMETHOD_H |
2 | #define APT_APTMETHOD_H | |
3 | ||
4 | #include <apt-pkg/acquire-method.h> | |
5 | ||
6 | #include <string> | |
7 | ||
8 | class aptMethod : public pkgAcqMethod | |
9 | { | |
10 | char const * const Binary; | |
11 | public: | |
12 | virtual bool Configuration(std::string Message) APT_OVERRIDE; | |
13 | ||
14 | bool CalculateHashes(FetchItem const * const Itm, FetchResult &Res) const; | |
15 | ||
16 | aptMethod(char const * const Binary, char const * const Ver, unsigned long const Flags) : pkgAcqMethod(Ver, Flags), Binary(Binary) {}; | |
17 | }; | |
18 | bool aptMethod::Configuration(std::string Message) | |
19 | { | |
20 | if (pkgAcqMethod::Configuration(Message) == false) | |
21 | return false; | |
22 | ||
23 | DropPrivsOrDie(); | |
24 | ||
25 | return true; | |
26 | } | |
27 | bool aptMethod::CalculateHashes(FetchItem const * const Itm, FetchResult &Res) const | |
28 | { | |
29 | Hashes Hash(Itm->ExpectedHashes); | |
30 | FileFd Fd; | |
31 | if (Fd.Open(Res.Filename, FileFd::ReadOnly) == false || Hash.AddFD(Fd) == false) | |
32 | return false; | |
33 | Res.TakeHashes(Hash); | |
34 | return true; | |
35 | } | |
36 | ||
37 | #endif |