From 81bf46849a82a9e7fa6e27cea6d506dd1e567d65 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 17 May 2014 01:51:07 -0700 Subject: [PATCH] Calculate last-update time for installed packages. --- MobileCydia.mm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index e207fa33..386ac11f 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1970,6 +1970,7 @@ struct ParsedPackage { CYString latest_; CYString installed_; + time_t updated_; const char *section_; _transient NSString *section$_; @@ -2458,13 +2459,21 @@ struct PackageNameOrdering : _profile(Package$initWithVersion$Metadata) const char *mixed(iterator.Name()); size_t size(strlen(mixed)); - char lower[size + 1]; + static const size_t prefix(sizeof("/var/lib/dpkg/info/") - 1); + char lower[prefix + size + 5 + 1]; for (size_t i(0); i != size; ++i) - lower[i] = mixed[i] | 0x20; - lower[size] = '\0'; + lower[prefix + i] = mixed[i] | 0x20; + + if (!installed_.empty()) { + memcpy(lower, "/var/lib/dpkg/info/", prefix); + memcpy(lower + prefix + size, ".list", 6); + struct stat info; + if (stat(lower, &info) != -1) + updated_ = info.st_birthtime; + } - PackageValue *metadata(PackageFind(lower, size)); + PackageValue *metadata(PackageFind(lower + prefix, size)); metadata_ = metadata; id_.set(NULL, metadata->name_, size); -- 2.45.2