ref: refs/heads/master
commit 2844754a38b421f800dd325e563d69373d54df5d
Author: Michael Andres
Date: Thu Jul 23 00:30:15 2009 +0200
Add ZYppFactory::haveZYpp test whether the ZYpp instance is already created.
---
zypp/ZYppFactory.cc | 24 ++++++++++++++++++------
zypp/ZYppFactory.h | 3 +++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/zypp/ZYppFactory.cc b/zypp/ZYppFactory.cc
index 5c38f6d..0a5a407 100644
--- a/zypp/ZYppFactory.cc
+++ b/zypp/ZYppFactory.cc
@@ -151,7 +151,8 @@ namespace zypp
bool lockFileExists()
{
Pathname lock_file = Pathname(ZYPP_LOCK_FILE);
- // check if the file already existed.
+ // check if the file already existed.
+ INT << PathInfo(lock_file) << endl;
bool exists = PathInfo(lock_file).isExist();
return exists;
}
@@ -293,7 +294,11 @@ namespace zypp
};
- static ZYppGlobalLock globalLock;
+ namespace
+ {
+ ZYppGlobalLock globalLock;
+ bool _haveZYpp = false;
+ }
///////////////////////////////////////////////////////////////////
//
@@ -350,13 +355,12 @@ namespace zypp
{
/*--------------------------------------------------*/
if ( zypp_readonly_hack::active )
- {
+ {
_instance = new ZYpp( ZYpp::Impl_Ptr(new ZYpp::Impl) );
MIL << "ZYPP_READONLY active." << endl;
- return _instance;
- }
+ }
/*--------------------------------------------------*/
- if ( globalLock.zyppLocked() )
+ else if ( globalLock.zyppLocked() )
{
std::string t = str::form(_("System management is locked by the application with pid %d (%s).\n"
"Close this application before trying again."),
@@ -370,11 +374,19 @@ namespace zypp
_instance = new ZYpp( ZYpp::Impl_Ptr(new ZYpp::Impl) );
globalLock._clean_lock = true;
}
+
+ if ( _instance )
+ _haveZYpp = true;
}
return _instance;
}
+ ///////////////////////////////////////////////////////////////////
+ //
+ bool ZYppFactory::haveZYpp() const
+ { return _haveZYpp; }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
diff --git a/zypp/ZYppFactory.h b/zypp/ZYppFactory.h
index d01f378..e17af7c 100644
--- a/zypp/ZYppFactory.h
+++ b/zypp/ZYppFactory.h
@@ -52,6 +52,9 @@ namespace zypp
*/
ZYpp::Ptr getZYpp() const;
+ /** Whether the ZYpp instance is already created.*/
+ bool haveZYpp() const;
+
private:
/** Default ctor. */
ZYppFactory();
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org