]> git.mxchange.org Git - simgear.git/commitdiff
Package::existingInstall helper.
authorJames Turner <zakalawe@mac.com>
Tue, 10 Jun 2014 20:21:30 +0000 (21:21 +0100)
committerJames Turner <zakalawe@mac.com>
Tue, 10 Jun 2014 20:21:30 +0000 (21:21 +0100)
simgear/package/Package.cxx
simgear/package/Package.hxx

index 772644e41b667d5eb4271e74116b3e3595b67272..fd3ec7e7d4872234890df49836a78832c4affccc 100644 (file)
@@ -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");
index 7346500e72b58f811e682423a2c1a276c2b7e0fe..43934ddf14af4784e67b2967843a790818fabe64 100644 (file)
@@ -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);