ref: refs/heads/master
commit 987f61e077b3706e04d6064143a753e4e6e438ac
Author: Michael Andres
Date: Fri Oct 9 13:47:31 2009 +0200
Added Pathname::showRoot/showRootIf: pretty print pathnames with optional root prefix.
---
zypp/Pathname.cc | 12 ++++++++++++
zypp/Pathname.h | 6 ++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/zypp/Pathname.cc b/zypp/Pathname.cc
index 76e53f8..1b41a89 100644
--- a/zypp/Pathname.cc
+++ b/zypp/Pathname.cc
@@ -241,6 +241,18 @@ namespace zypp
return ret;
}
+ std::string Pathname::showRoot( const Pathname & root_r, const Pathname & path_r )
+ {
+ return str::Str() << "(" << root_r << ")" << path_r;
+ }
+
+ std::string Pathname::showRootIf( const Pathname & root_r, const Pathname & path_r )
+ {
+ if ( root_r.empty() || root_r == "/" )
+ return path_r.asString();
+ return showRoot( root_r, path_r );
+ }
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Pathname::extension
diff --git a/zypp/Pathname.h b/zypp/Pathname.h
index 0632536..a93c4b3 100644
--- a/zypp/Pathname.h
+++ b/zypp/Pathname.h
@@ -80,6 +80,12 @@ namespace zypp
const std::string & asString() const
{ return name_t; }
+ /** String representation as "(root)/path" */
+ static std::string showRoot( const Pathname & root_r, const Pathname & path_r );
+
+ /** String representation as "(root)/path", unless \a root is \c "/" or empty. */
+ static std::string showRootIf( const Pathname & root_r, const Pathname & path_r );
+
/** Url representation using \c dir schema. */
Url asUrl() const;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org