]>
git.saurik.com Git - apt.git/blob - methods/aptmethod.h
1 #ifndef APT_APTMETHOD_H
2 #define APT_APTMETHOD_H
4 #include <apt-pkg/acquire-method.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/error.h>
12 #include <sys/types.h>
18 class aptMethod
: public pkgAcqMethod
24 virtual bool Configuration(std::string Message
) APT_OVERRIDE
26 if (pkgAcqMethod::Configuration(Message
) == false)
29 std::string
const conf
= std::string("Binary::") + Binary
;
30 _config
->MoveSubTree(conf
.c_str(), NULL
);
37 bool CalculateHashes(FetchItem
const * const Itm
, FetchResult
&Res
) const
39 Hashes
Hash(Itm
->ExpectedHashes
);
41 if (Fd
.Open(Res
.Filename
, FileFd::ReadOnly
) == false || Hash
.AddFD(Fd
) == false)
47 void Warning(const char *Format
,...)
50 va_start(args
,Format
);
51 PrintStatus("104 Warning", Format
, args
);
55 bool TransferModificationTimes(char const * const From
, char const * const To
, time_t &LastModified
)
57 if (strcmp(To
, "/dev/null") == 0)
61 if (lstat(To
, &Buf2
) != 0 || S_ISLNK(Buf2
.st_mode
))
65 if (stat(From
, &Buf
) != 0)
66 return _error
->Errno("stat",_("Failed to stat"));
68 // we don't use utimensat here for compatibility reasons: #738567
69 struct timeval times
[2];
70 times
[0].tv_sec
= Buf
.st_atime
;
71 LastModified
= times
[1].tv_sec
= Buf
.st_mtime
;
72 times
[0].tv_usec
= times
[1].tv_usec
= 0;
73 if (utimes(To
, times
) != 0)
74 return _error
->Errno("utimes",_("Failed to set modification time"));
78 aptMethod(char const * const Binary
, char const * const Ver
, unsigned long const Flags
) :
79 pkgAcqMethod(Ver
, Flags
), Binary(Binary
)
82 std::locale::global(std::locale(""));
84 setlocale(LC_ALL
, "");