Package::existingInstall helper.

This commit is contained in:
James Turner 2014-06-10 21:21:30 +01:00
parent adebbe006b
commit a8c8148068
2 changed files with 23 additions and 7 deletions

View 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");

View 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);