From: James Turner Date: Tue, 10 Jun 2014 20:21:30 +0000 (+0100) Subject: Package::existingInstall helper. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a8c81480685acdf23d7b3af113bd3b043547086d;p=simgear.git Package::existingInstall helper. --- diff --git a/simgear/package/Package.cxx b/simgear/package/Package.cxx index 772644e4..fd3ec7e7 100644 --- a/simgear/package/Package.cxx +++ b/simgear/package/Package.cxx @@ -97,19 +97,21 @@ bool Package::matches(const SGPropertyNode* aFilter) const bool Package::isInstalled() const { - SGPath p(m_catalog->installRoot()); - p.append("Aircraft"); - p.append(id()); - // anything to check for? look for a valid revision file? - return p.exists(); + return pathOnDisk().exists(); } -InstallRef Package::install() +SGPath Package::pathOnDisk() const { SGPath p(m_catalog->installRoot()); p.append("Aircraft"); p.append(id()); + return p; +} + +InstallRef Package::install() +{ + SGPath p(pathOnDisk()); if (p.exists()) { return Install::createFromPath(p, m_catalog); } @@ -119,6 +121,16 @@ InstallRef Package::install() return ins; } +InstallRef Package::existingInstall() const +{ + SGPath p(pathOnDisk()); + if (p.exists()) { + return Install::createFromPath(p, m_catalog); + } + + return NULL; +} + std::string Package::id() const { return m_props->getStringValue("id"); diff --git a/simgear/package/Package.hxx b/simgear/package/Package.hxx index 7346500e..43934ddf 100644 --- a/simgear/package/Package.hxx +++ b/simgear/package/Package.hxx @@ -53,7 +53,9 @@ public: * get or create an install for the package */ InstallRef install(); - + + InstallRef existingInstall() const; + bool isInstalled() const; std::string id() const; @@ -102,6 +104,8 @@ public: */ PackageList dependencies() const; private: + SGPath pathOnDisk() const; + friend class Catalog; Package(const SGPropertyNode* aProps, CatalogRef aCatalog);