ref: refs/heads/ma-misc
commit 4a22801c8e1c95236b49c08996ae7a7901371bfe
Author: Michael Andres
Date: Thu Sep 10 19:10:44 2009 +0200
Url: Add tests schemeIsLocal,Remote,Volatile,Downloading and scheme snfs4
---
zypp/Url.cc | 37 +++++++++++++++++++++++++++++++++++++
zypp/Url.h | 20 ++++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/zypp/Url.cc b/zypp/Url.cc
index 9c6b42f..7ca3c61 100644
--- a/zypp/Url.cc
+++ b/zypp/Url.cc
@@ -205,6 +205,7 @@ namespace zypp
ref.reset( new UrlBase());
ref->config("require_host", "m"); // host is mandatory
addUrlByScheme("nfs", ref);
+ addUrlByScheme("nfs4", ref);
addUrlByScheme("smb", ref);
addUrlByScheme("cifs", ref);
addUrlByScheme("http", ref);
@@ -438,6 +439,42 @@ namespace zypp
}
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ {
+ inline bool isInList( const char ** begin_r, const char ** end_r, const std::string & scheme_r )
+ {
+ for ( ; begin_r != end_r; ++begin_r )
+ if ( scheme_r == *begin_r )
+ return true;
+ return false;
+ }
+ }
+ bool Url::schemeIsLocal( const std::string & scheme_r )
+ {
+ static const char * val[] = { "cd", "dvd", "dir", "hd", "iso", "file" };
+ return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
+ }
+
+ bool Url::schemeIsRemote( const std::string & scheme_r )
+ {
+ static const char * val[] = { "http", "https", "nfs", "nfs4", "smb", "cifs", "ftp", "sftp" };
+ return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
+ }
+
+ bool Url::schemeIsVolatile( const std::string & scheme_r )
+ {
+ static const char * val[] = { "cd", "dvd" };
+ return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
+ }
+
+ bool Url::schemeIsDownloading( const std::string & scheme_r )
+ {
+ static const char * val[] = { "http", "https", "ftp", "sftp" };
+ return isInList( arrayBegin(val), arrayEnd(val), scheme_r );
+ }
+ ///////////////////////////////////////////////////////////////////
+
// -----------------------------------------------------------------
bool
Url::isValid() const
diff --git a/zypp/Url.h b/zypp/Url.h
index d3f0cec..e56bb17 100644
--- a/zypp/Url.h
+++ b/zypp/Url.h
@@ -247,6 +247,26 @@ namespace zypp
isValidScheme(const std::string &scheme) const;
+ /** hd cd dvd dir file iso */
+ static bool schemeIsLocal( const std::string & scheme_r );
+ /** \overload nonstatic version */
+ bool schemeIsLocal() const { return schemeIsLocal( getScheme() ); }
+
+ /** nfs nfs4 smb cifs http https ftp sftp */
+ static bool schemeIsRemote( const std::string & scheme_r );
+ /** \overload nonstatic version */
+ bool schemeIsRemote() const { return schemeIsRemote( getScheme() ); }
+
+ /** cd dvd */
+ static bool schemeIsVolatile( const std::string & scheme_r );
+ /** \overload nonstatic version */
+ bool schemeIsVolatile() const { return schemeIsVolatile( getScheme() ); }
+
+ /** http https ftp sftp */
+ static bool schemeIsDownloading( const std::string & scheme_r );
+ /** \overload nonstatic version */
+ bool schemeIsDownloading() const { return schemeIsDownloading( getScheme() ); }
+
/**
* \brief Verifies the Url.
*
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org