diff options
author | Enrico Zini <enrico@enricozini.org> | 2015-09-10 14:22:54 +0200 |
---|---|---|
committer | Enrico Zini <enrico@enricozini.org> | 2015-09-10 14:22:54 +0200 |
commit | c47c2df9f80e30939db705b79cfbd88a7606ce00 (patch) | |
tree | 13933b5460fb7b6acba2a5909be9d0e91e254233 | |
parent | a63d4ba12a83b6c6cf6e6cd17d4076d0181b056b (diff) | |
download | libept-c47c2df9f80e30939db705b79cfbd88a7606ce00.tar.gz |
No wibble used for apt/ anymore
-rw-r--r-- | ept/apt/apt-test.cc | 8 | ||||
-rw-r--r-- | ept/apt/apt.cc | 47 | ||||
-rw-r--r-- | ept/apt/apt.h | 15 |
3 files changed, 33 insertions, 37 deletions
diff --git a/ept/apt/apt-test.cc b/ept/apt/apt-test.cc index 7646010..1a34f50 100644 --- a/ept/apt/apt-test.cc +++ b/ept/apt/apt-test.cc @@ -129,9 +129,9 @@ class Tests : public TestCase wassert_true(record.find("Section: text") != string::npos); record = apt.rawRecord(Version("sp", "0.31415")); - assert_eq(record, string()); + wassert(actual(record) == string()); - assert_eq(apt.rawRecord(pkg), apt.rawRecord(apt.anyVersion(pkg))); + wassert(actual(apt.rawRecord(pkg)) == apt.rawRecord(apt.anyVersion(pkg))); }); add_method("state", []() { @@ -155,7 +155,7 @@ class Tests : public TestCase i != apt.recordEnd(); ++i) { wassert_true((*i).size() > 8); - assert_eq((*i).substr(0, 8), "Package:"); + wassert(actual((*i).substr(0, 8)) == "Package:"); ++count; } wassert_true(count > 200); @@ -170,7 +170,7 @@ class Tests : public TestCase i != apt.recordEnd(); ++i) { wassert_true(i->size() > 8); - assert_eq(i->substr(0, 8), "Package:"); + wassert(actual(i->substr(0, 8)) == "Package:"); ++count; } wassert_true(count > 200); diff --git a/ept/apt/apt.cc b/ept/apt/apt.cc index f3552f9..eba01f2 100644 --- a/ept/apt/apt.cc +++ b/ept/apt/apt.cc @@ -20,8 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <ept/apt/apt.h> - +#include "apt.h" +#include "ept/utils/sys.h" #include <apt-pkg/error.h> #include <apt-pkg/init.h> #include <apt-pkg/progress.h> @@ -29,12 +29,8 @@ #include <apt-pkg/pkgcachegen.h> #include <apt-pkg/policy.h> #include <apt-pkg/cachefile.h> - -#include <wibble/sys/fs.h> - #include <vector> #include <algorithm> - #include <iostream> using namespace std; @@ -44,29 +40,36 @@ namespace apt { static time_t aptTimestamp() { - namespace wfs = wibble::sys::fs; + time_t t1 = sys::timestamp(_config->FindFile("Dir::Cache::pkgcache"), 0); + time_t t2 = sys::timestamp(_config->FindFile("Dir::State::status"), 0); - time_t t1 = wfs::timestamp(_config->FindFile("Dir::Cache::pkgcache"), 0); - time_t t2 = wfs::timestamp(_config->FindFile("Dir::State::status"), 0); - return t1 > t2 ? t1 : t2; } -Exception::Exception(const std::string& context) throw () - : Generic(context) +static std::string apt_annotate_error_message(const std::string& message) { - // Concatenate all errors and warnings found - string err; - while (!_error->empty()) - { - bool type = _error->PopMessage(err); - if (type) - m_message += "E: " + err + "\n"; - else - m_message += "W: " + err + "\n"; - } + string res = message; + res += ":\n"; + // Concatenate all errors and warnings found + string err; + while (!_error->empty()) + { + bool type = _error->PopMessage(err); + if (type) + res += "E: " + err + "\n"; + else + res += "W: " + err + "\n"; + } + return res; } +Exception::Exception(const std::string& message) + : std::runtime_error(apt_annotate_error_message(message)) +{ +} + +Exception::~Exception() {} + static void aptInit () { if (_config->FindB("Initialized")) diff --git a/ept/apt/apt.h b/ept/apt/apt.h index 6e6ce74..3f41f5d 100644 --- a/ept/apt/apt.h +++ b/ept/apt/apt.h @@ -24,27 +24,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <wibble/exception.h> #include <ept/apt/version.h> - #include <iterator> +#include <stdexcept> class pkgCache; namespace ept { namespace apt { -class Exception : public wibble::exception::Generic +class Exception : public std::runtime_error { -protected: - std::string m_message; - public: - Exception(const std::string& context) throw (); - ~Exception() throw () {} - - virtual const char* type() const throw () { return "Apt"; } - virtual std::string desc() const throw () { return m_message; } + Exception(const std::string& message); + ~Exception(); }; class Apt; |