MediaException.h \
MediaAccess.h \
MediaHandler.h \
- Mount.h
-
-# MediaCurl.h
+ Mount.h \
+ MediaCurl.h
+# MediaNFS.h
noinst_LTLIBRARIES = lib@PACKAGE@_media.la
## ##################################################
lib@PACKAGE@_media_la_SOURCES = \
+ MediaException.cc \
MediaAccess.cc \
MediaHandler.cc \
- Mount.cc
+ Mount.cc \
+ MediaCurl.cc
-# MediaCurl.cc
+# MediaNFS.cc
lib@PACKAGE@_media_la_LIBADD = -lcurl
#include "zypp/media/MediaCD.h"
#include "zypp/media/MediaDIR.h"
#include "zypp/media/MediaDISK.h"
-#include "zypp/media/MediaNFS.h"
#include "zypp/media/MediaSMB.h"
#include "zypp/media/MediaCIFS.h"
+#include "zypp/media/MediaNFS.h"
*/
-//#include "zypp/media/MediaCurl.h"
+#include "zypp/media/MediaCurl.h"
using namespace std;
// destructor
MediaAccess::~MediaAccess()
{
-#warning FIXME uncomment
-#if 0
DBG << *this << endl;
-#endif
close(); // !!! make sure handler gets properly deleted.
}
void
MediaAccess::open (const Url& url, const Pathname & preferred_attach_point)
{
-#warning FIXME uncomment once media backends get ready
-#if 0
if(!url.isValid()) {
- ERR << Error::E_bad_url << " opening " << url << endl;
- return Error::E_bad_url;
+ ZYPP_DOTHROW(MediaBadUrlException(url));
}
close();
+#warning FIXME uncomment once media backends get ready
+#if 0
switch ( url.protocol() ) {
case Url::cd:
case Url::dvd:
}
// Type of media if open, otherwise NONE.
-#warning FIXME uncomment once real Url class is implemented
-#if 0
-Url::Protocol
+std::string
MediaAccess::protocol() const
{
if ( !_handler )
- return Url::unknown;
+ return "unknown";
return _handler->protocol();
}
-#endif
///////////////////////////////////////////////////////////////////
//
}
catch (const MediaException & excpt_r)
{
-#warning FIXME uncomment, rethrow
-#if 0
- WAR << "Close: " << *this << " (" << err << ")" << endl;
+ ZYPP_CAUGHT(excpt_r);
+ WAR << "Close: " << *this << " (" << excpt_r << ")" << endl;
ZYPP_RETHROW(excpt_r);
-#endif
}
-#warning FIXME uncomment
-#if 0
- MIL << "Close: " << *this << " (" << err << ")" << endl;
-#endif
+ MIL << "Close: " << *this << " (OK)" << endl;
delete _handler;
_handler = 0;
}
void MediaAccess::attach (bool next)
{
if ( !_handler ) {
- INT << "Error::E_not_open" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->attach(next);
}
MediaAccess::disconnect()
{
if ( !_handler )
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ ZYPP_DOTHROW(MediaNotOpenException());
_handler->disconnect();
}
}
if(checkonly)
- ZYPP_THROW( MediaException, "Error::E_error");
+ ZYPP_DOTHROW(MediaFileNotFoundException(url(), filename));
if ( !_handler ) {
- INT << "Error::E_not_open" << " on provideFile(" << filename << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << " on provideFile(" << filename << ")" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->provideFile( filename );
MediaAccess::provideDir( const Pathname & dirname ) const
{
if ( !_handler ) {
- INT << "Error::E_not_open" << " on provideDir(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << " on provideDir(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->provideDir( dirname );
MediaAccess::provideDirTree( const Pathname & dirname ) const
{
if ( !_handler ) {
- INT << "Error::E_not_open" << " on provideDirTree(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << " on provideDirTree(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->provideDirTree( dirname );
retlist.clear();
if ( !_handler ) {
- INT << "Error::E_not_open" << " on dirInfo(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << " on dirInfo(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->dirInfo( retlist, dirname, dots );
retlist.clear();
if ( !_handler ) {
- INT << "Error::E_not_open" << " on dirInfo(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_open");
+ INT << "Error::E_media_not_open" << " on dirInfo(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotOpenException());
}
_handler->dirInfo( retlist, dirname, dots );
if ( !_handler )
return str << "MediaAccess( closed )";
-#warning FIXME uncomment once real Url class is implemented
-#if 0
- string tstr = Url::protocolToString( _handler->protocol() );
- str << tstr << "(" << *_handler << ")";
-#endif
+ str << _handler->protocol() << "(" << *_handler << ")";
return str;
}
{
DBG << "From: " << from << endl << "To: " << to << endl;
- Pathname path
-#warning FIXME uncomment once real Url class is implemented
-#if 0
- = from.path()
-#endif
-;
+ Pathname path = from.getPathData();
Pathname dir = path.dirname();
string base = path.basename();
Url u = from;
-#warning FIXME uncomment once real Url class is implemented
-#if 0
- u.setPath( dir.asString() );
-#endif
+ u.setPathData( dir.asString() );
MediaAccess media;
}
catch (const MediaException & excpt_r)
{
-#warning FIXME uncomment, add message into log
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
}
+ std::ostream & operator<<( std::ostream & str, const MediaAccess & obj )
+ { return obj.dumpOn( str ); }
///////////////////////////////////////////////////////////////////
} // namespace media
#include "zypp/PathInfo.h"
#include "zypp/media/MediaException.h"
-
-#warning FIXME use real Url class
-// #include "zypp/@Review/Url.h"
-typedef std::string Url;
+#include "zypp/Url.h"
namespace zypp {
namespace media {
/**
* Used Protocol if media is opened, otherwise 'unknown'.
**/
-#warning FIXME uncomment once real Url class is implemented
-#if 0
- Url::Protocol protocol() const;
-#endif
+ std::string protocol() const;
/**
* Url if media is opened, otherwise empty.
* Currently we can not releaseFile after the media was closed
* (it's passed to the handler, which is deleted on close).
*
+ * \throws MediaBadFilenameException
* \throws MediaException
**/
class FileProvider {
, _local_file( "" )
{
if ( _file.empty() ) {
- ZYPP_THROW( MediaException, "E_bad_filename");
+ ZYPP_DOTHROW(MediaBadFilenameException(_file.asString()));
} else if ( _media ) {
try {
_media->provideFile( _file );
}
catch (const MediaException & excpt_r)
{
+ ZYPP_CAUGHT(excpt_r);
_media = NULL;
-#warning FIXME rethrow the exception
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
}
}
}
catch (const MediaException &excpt_r)
{
+ ZYPP_CAUGHT(excpt_r);
INT << "Exception raised while releasing file" << std::endl;
}
}
};
};
+ std::ostream & operator<<( std::ostream & str, const MediaAccess & obj );
+
///////////////////////////////////////////////////////////////////
} // namespace media
#include "zypp/base/Logger.h"
#include "zypp/ExternalProgram.h"
+#include "zypp/base/String.h"
//#include <y2util/SysConfig.h>
#include "zypp/media/MediaCurl.h"
if ( next )
ZYPP_THROW( MediaException, "Error::E_not_supported_by_media");
+#warning FIXME implement check for URL validity
+#if 0
if ( !_url.isValid() )
ZYPP_THROW( MediaException, "Error::E_bad_url");
+#endif
_curl = curl_easy_init();
if ( !_curl ) {
ZYPP_THROW( MediaException, "Error::E_curl_setopt_failed");
}
- if ( _url.protocol() == Url::http ) {
+ if ( _url.getScheme() == "http" ) {
// follow any Location: header that the server sends as part of
// an HTTP header (#113275)
ret = curl_easy_setopt ( _curl, CURLOPT_FOLLOWLOCATION, true );
// XXX: wasn't that the wrong fix for some problem? this should be
// removed
- if ( _url.protocol() == Url::https ) {
+ if ( _url.getScheme() == "https" ) {
WAR << "Disable certificate verification for https." << endl;
ret = curl_easy_setopt( _curl, CURLOPT_SSL_VERIFYPEER, 0 );
if ( ret != 0 ) {
If not provided, anonymous FTP identification
*---------------------------------------------------------------*/
- if ( _url.username().empty() ) {
- if ( _url.protocol() == Url::ftp ) {
+ if ( _url.getUsername().empty() ) {
+ if ( _url.getScheme() == "ftp" ) {
string id = "yast2@";
id += VERSION;
DBG << "Anonymous FTP identification: '" << id << "'" << endl;
_userpwd = "anonymous:" + id;
}
} else {
- _userpwd = _url.username();
- if ( _url.password().size() ) {
- _userpwd += ":" + _url.password();
+ _userpwd = _url.getUsername();
+ if ( _url.getPassword().size() ) {
+ _userpwd += ":" + _url.getPassword();
}
}
If not provided, /etc/sysconfig/proxy is evaluated
*---------------------------------------------------------------*/
+#warning FIX once I understand how to get this info
+#warning FIXME enable proxy via sysconfig somehow
+#if 0
_proxy = _url.option( "proxy" );
if ( ! _proxy.empty() ) {
if ( ! proxyport.empty() ) {
_proxy += ":" + proxyport;
}
-
-#warning FIXME enable proxy via sysconfig somehow
-#if 0
} else {
SysConfig cfg( "proxy" );
for ( unsigned i = 0; i < nope.size(); ++i ) {
// no proxy: if nope equals host,
// or is a suffix preceeded by a '.'
- string::size_type pos = _url.host().find( nope[i] );
+ string::size_type pos = _url.getHost().find( nope[i] );
if ( pos != string::npos
- && ( pos + nope[i].size() == _url.host().size() )
- && ( pos == 0 || _url.host()[pos -1] == '.' ) ) {
- DBG << "NO_PROXY: " << nope[i] << " matches host " << _url.host() << endl;
+ && ( pos + nope[i].size() == _url.getHost().size() )
+ && ( pos == 0 || _url.getHost()[pos -1] == '.' ) ) {
+ DBG << "NO_PROXY: " << nope[i] << " matches host " << _url.getHost() << endl;
useproxy = false;
break;
}
}
if ( useproxy ) {
- if ( _url.protocol() == Url::ftp ) {
+ if ( _url.getScheme() == Url::ftp ) {
_proxy = cfg.readEntry( "FTP_PROXY" );
- } else if ( _url.protocol() == Url::http ) {
+ } else if ( _url.getScheme() == Url::http ) {
_proxy = cfg.readEntry( "HTTP_PROXY" );
- } else if ( _url.protocol() == Url::https ) {
+ } else if ( _url.getScheme() == Url::https ) {
_proxy = cfg.readEntry( "HTTPS_PROXY" );
}
}
}
-#endif
}
+#endif
DBG << "Proxy: " << _proxy << endl;
If not provided, $HOME/.curlrc is evaluated
*---------------------------------------------------------------*/
+#warning FIXME once I know how to get this info
+#warning FIXME enable proxy via sysconfig somehow
+#if 0
_proxyuserpwd = _url.option( "proxyuser" );
if ( ! _proxyuserpwd.empty() ) {
_proxyuserpwd += ":" + proxypassword;
}
-#warning FIXME enable proxy via sysconfig somehow
-#if 0
} else {
string curlrcFile = string( getenv("HOME") ) + string( "/.curlrc" );
SysConfig curlrc( curlrcFile );
_proxyuserpwd = curlrc.readEntry( "proxy-user" );
-#endif
}
+#endif
_proxyuserpwd = unEscape( _proxyuserpwd );
ret = curl_easy_setopt( _curl, CURLOPT_PROXYUSERPWD, _proxyuserpwd.c_str() );
{
DBG << filename.asString() << endl;
+#warning FIXME implement check for URL validity
+#if 0
if(!_url.isValid())
- ZYPP_THROW( MediaException, string("Error::E_bad_url") + " " + _url.asString());
+ ZYPP_THROW( MediaException, string("Error::E_bad_url") + " " + _url.toString());
+#endif
- if(_url.host().empty())
+ if(_url.getHost().empty())
ZYPP_THROW( MediaException, "Error::E_no_host_specified");
- string path = _url.path();
+ string path = _url.getPathName();
if ( !path.empty() && path != "/" && *path.rbegin() == '/' &&
filename.absolute() ) {
// If url has a path with trailing slash, remove the leading slash from
}
Url url( _url );
- url.setPath( escapedPath(path) );
+ url.setPathName( escapedPath(path) );
Pathname dest = target.absolutename();
string destNew = target.asString() + ".new.yast.37456";
ZYPP_THROW( MediaException, string("Error::E_system") + string(" ") + dest.dirname().asString());
}
- DBG << "URL: " << url.asString().c_str() << endl;
+ DBG << "URL: " << url.toString().c_str() << endl;
// Use URL without options (not RFC conform) and without
// username and passwd (some proxies dislike them in the URL.
// Curloptions for these were set in attachTo().
Url curlUrl( url );
curlUrl.setUsername( "" );
curlUrl.setPassword( "" );
- string urlBuffer = curlUrl.asString(true,false,true); // without options
+#warning Check whether the call is correct
+// string urlBuffer = curlUrl.toString(true,false,true); // without options
+ string urlBuffer = curlUrl.toString(); // without options
CURLcode ret = curl_easy_setopt( _curl, CURLOPT_URL,
urlBuffer.c_str() );
}
if ( ret != 0 ) {
- unlink( destNew );
+ filesystem::unlink( destNew );
ERR << "curl error: " << ret << ": " << _curlError << endl;
std::string err;
&httpReturnCode );
if ( infoRet == CURLE_OK ) {
string msg = "HTTP return code: " +
- stringutil::numstring( httpReturnCode ) +
- " (URL: " + url.asString() + ")";
+ str::numstring( httpReturnCode ) +
+ " (URL: " + url.toString() + ")";
DBG << msg << endl;
if ( httpReturnCode == 401 )
{
- msg = "URL: " + url.asString();
+ msg = "URL: " + url.toString();
err = "Error::E_login_failed";
}
else
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/MediaException.cc
+ *
+*/
+
+#include <string>
+#include <iostream>
+
+#include "zypp/media/MediaException.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ namespace media {
+ /////////////////////////////////////////////////////////////////
+
+ std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
+ {
+ return str << "Failed to mount " << _source << " on " << _target
+ << " : " << _error << endl;
+ }
+
+ std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
+ {
+ return str << "Failed to unmount " << _path
+ << " : " << _error << endl;
+ }
+
+ std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str ) const
+ {
+ return str << "Bad file name " << _filename << endl;
+ }
+
+ std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
+ {
+ return str << "Media not opened." << endl;
+ }
+
+ std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str) const
+ {
+ return str << "File " << _filename
+ << " not found on media: " << _url << endl;
+ }
+
+ std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
+ {
+ return str << "Cannot write file " << _filename << endl;
+ }
+
+ std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
+ {
+ return str << "Media not attached: " << _url << endl;
+ }
+
+ std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
+ {
+ return str << "System exception: " << _message
+ << " on media: " << _url << endl;
+ }
+
+ std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
+ {
+ return str << "Path " << _path
+ << " on media: " << _url
+ << " is not a file." << endl;
+ }
+
+ std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
+ {
+ return str << "Path " << _path
+ << " on media: " << _url
+ << " is not a directory." << endl;
+ }
+
+ std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
+ {
+ return str << "Malformed URL: " << _url << endl;
+ }
+
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace media
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
#include <string>
#include "zypp/base/Exception.h"
+#include "zypp/Pathname.h"
+#include "zypp/Url.h"
///////////////////////////////////////////////////////////////////
namespace zypp
/** Ctor taking message.
* Use \ref ZYPP_DOTHROW to throw exceptions.
*/
- MediaMountException( const std::string & msg_r,
+ MediaMountException( const std::string & error_r,
const std::string & source_r,
const std::string & target_r )
- : MediaException( msg_r )
+ : MediaException()
+ , _error(error_r)
, _source(source_r)
, _target(target_r)
{}
/** Dtor. */
virtual ~MediaMountException() throw() {};
- std::string source() const { return _source; }
- std::string target() const { return _target; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
+ std::string _error;
std::string _source;
std::string _target;
};
/** Ctor taking message.
* Use \ref ZYPP_DOTHROW to throw exceptions.
*/
- MediaUnmountException( const std::string & msg_r,
+ MediaUnmountException( const std::string & error_r,
const std::string & path_r )
- : MediaException( msg_r )
+ : MediaException()
+ , _error(error_r)
, _path(path_r)
{}
/** Dtor. */
virtual ~MediaUnmountException() throw() {};
- std::string path() const { return _path; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
+ std::string _error;
std::string _path;
};
+ class MediaBadFilenameException : public MediaException
+ {
+ public:
+ MediaBadFilenameException(const std::string & filename_r)
+ : MediaException()
+ , _filename(filename_r)
+ {}
+ virtual ~MediaBadFilenameException() throw() {};
+ std::string filename() const { return _filename; }
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _filename;
+ };
+
+ class MediaNotOpenException : public MediaException
+ {
+ public:
+ MediaNotOpenException()
+ : MediaException()
+ {}
+ virtual ~MediaNotOpenException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ };
+
+ class MediaFileNotFoundException : public MediaException
+ {
+ public:
+ MediaFileNotFoundException(const Url & url_r,
+ const Pathname & filename_r)
+ : MediaException()
+ , _url(url_r.toString())
+ , _filename(filename_r.asString())
+ {}
+ virtual ~MediaFileNotFoundException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _filename;
+ };
+
+ class MediaWriteException : public MediaException
+ {
+ public:
+ MediaWriteException(const Pathname & filename_r)
+ : MediaException()
+ , _filename(filename_r.asString())
+ {}
+ virtual ~MediaWriteException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _filename;
+ };
+
+ class MediaNotAttachedException : public MediaException
+ {
+ public:
+ MediaNotAttachedException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.toString())
+ {}
+ virtual ~MediaNotAttachedException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+ class MediaSystemException : public MediaException
+ {
+ public:
+ MediaSystemException(const Url & url_r,
+ const std::string & message_r)
+ : MediaException()
+ , _url(url_r.toString())
+ , _message(message_r)
+ {}
+ virtual ~MediaSystemException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _message;
+ };
+
+ class MediaNotAFileException : public MediaException
+ {
+ public:
+ MediaNotAFileException(const Url & url_r,
+ const Pathname & path_r)
+ : MediaException()
+ , _url(url_r.toString())
+ , _path(path_r.asString())
+ {}
+ virtual ~MediaNotAFileException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _path;
+ };
+
+ class MediaNotADirException : public MediaException
+ {
+ public:
+ MediaNotADirException(const Url & url_r,
+ const Pathname & path_r)
+ : MediaException()
+ , _url(url_r.toString())
+ , _path(path_r.asString())
+ {}
+ virtual ~MediaNotADirException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ std::string _path;
+ };
+
+ class MediaBadUrlException : public MediaException
+ {
+ public:
+ MediaBadUrlException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.toString())
+ {}
+ virtual ~MediaBadUrlException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+
+
/////////////////////////////////////////////////////////////////
} // namespace media
} // namespace zypp
catch (const MediaException & excpt_r)
{
WAR << "Attach failed: " << excpt_r << " " << *this << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
_isAttached = true;
MIL << "Attached: " << *this << endl;
catch (const MediaException & excpt_r)
{
WAR << "Disconnect failed: " << excpt_r << " " << *this << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
MIL << "Disconnected: " << *this << endl;
}
catch (const MediaException & excpt_r)
{
WAR << "Release failed: " << excpt_r << " " << *this << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
_isAttached = false;
MIL << "Released: " << *this << endl;
if ( !_isAttached ) {
INT << "Error::E_not_attached" << " on provideFileCopy(" << srcFilename
<< "," << targetFilename << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
catch (const MediaException & excpt_r)
{
WAR << "provideFileCopy(" << srcFilename << "," << targetFilename << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
DBG << "provideFileCopy(" << srcFilename << "," << targetFilename << ")" << endl;
}
void MediaHandler::provideFile( Pathname filename ) const
{
if ( !_isAttached ) {
- INT << "Error::E_not_attached" << " on provideFile(" << filename << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ INT << "Error: Not attached on provideFile(" << filename << ")" << endl;
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
catch (const MediaException & excpt_r)
{
WAR << "provideFile(" << filename << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
DBG << "provideFile(" << filename << ")" << endl;
}
void MediaHandler::provideDir( Pathname dirname ) const
{
if ( !_isAttached ) {
- INT << "Error::E_not_attached" << " on provideDir(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ INT << "Error: Not attached on provideDir(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
getDir( dirname, /*recursive*/false ); // pass to concrete handler
catch (const MediaException & excpt_r)
{
WAR << "provideDir(" << dirname << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
MIL << "provideDir(" << dirname << ")" << endl;
}
void MediaHandler::provideDirTree( Pathname dirname ) const
{
if ( !_isAttached ) {
- INT << "Error::E_not_attached" << " on provideDirTree(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ INT << "Error Not attached on provideDirTree(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
catch (const MediaException & excpt_r)
{
WAR << "provideDirTree(" << dirname << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
MIL << "provideDirTree(" << dirname << ")" << endl;
retlist.clear();
if ( !_isAttached ) {
- INT << "Error::E_not_attached" << " on dirInfo(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ INT << "Error: Not attached on dirInfo(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
catch (const MediaException & excpt_r)
{
WAR << "dirInfo(" << dirname << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
MIL << "dirInfo(" << dirname << ")" << endl;
}
retlist.clear();
if ( !_isAttached ) {
- INT << "Error::E_not_attached" << " on dirInfo(" << dirname << ")" << endl;
- ZYPP_THROW( MediaException, "Error::E_not_attached");
+ INT << "Error: Not attached on dirInfo(" << dirname << ")" << endl;
+ ZYPP_DOTHROW(MediaNotAttachedException(url()));
}
try {
catch (const MediaException & excpt_r)
{
WAR << "dirInfo(" << dirname << "): " << excpt_r << endl;
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
MIL << "dirInfo(" << dirname << ")" << endl;
}
}
catch (const MediaException & excpt_r)
{
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
// convert to std::list<std::string>
}
catch (const MediaException & excpt_r)
{
-#warning FIXME rethrow
-#if 0
ERR << "provideFile(" << dirFile << "): " << excpt_r << endl;
ZYPP_RETHROW(excpt_r);
-#endif
}
DBG << "provideFile(" << dirFile << "): " << "OK" << endl;
ifstream dir( localPath( dirFile ).asString().c_str() );
if ( dir.fail() ) {
ERR << "Unable to load '" << localPath( dirFile ) << "'" << endl;
- ZYPP_THROW( MediaException, "Error::E_system");
+ ZYPP_DOTHROW(MediaSystemException(url(),
+ "Unable to load '" + localPath( dirFile ).asString() + "'"));
}
string line;
}
if (info.isExist())
- ZYPP_THROW( MediaException, "Error::E_not_a_file");
+ ZYPP_DOTHROW(MediaNotAFileException(url(), localPath(filename)));
else
- ZYPP_THROW( MediaException, "Error::E_file_not_found");
+ ZYPP_DOTHROW(MediaFileNotFoundException(url(), filename));
}
}
catch (const MediaException & excpt_r)
{
-#warning FIXME rethrow
-#if 0
ZYPP_RETHROW(excpt_r);
-#endif
}
if ( copy( localPath( srcFilename ), targetFilename ) != 0 ) {
- ZYPP_THROW( MediaException, "Error::E_write_error");
+ ZYPP_DOTHROW(MediaWriteException(targetFilename));
}
}
}
if (info.isExist())
- ZYPP_THROW( MediaException, "Error::E_not_a_file");
+ ZYPP_DOTHROW(MediaNotADirException(url(), localPath(dirname)));
else
- ZYPP_THROW( MediaException, "Error::E_file_not_found");
+ ZYPP_DOTHROW(MediaFileNotFoundException(url(), dirname));
}
///////////////////////////////////////////////////////////////////
{
PathInfo info( localPath( dirname ) );
if( ! info.isDir() ) {
- ZYPP_THROW( MediaException, "Error::E_not_a_directory");
+ ZYPP_DOTHROW(MediaNotADirException(url(), localPath(dirname)));
}
#if NONREMOTE_DIRECTORY_YAST
// readdir
int res = readdir( retlist, info.path(), dots );
if ( res )
- ZYPP_THROW( MediaException, "Error::E_system");
+ ZYPP_DOTHROW(MediaSystemException(url(), "readdir failed"));
#if NONREMOTE_DIRECTORY_YAST
}
{
PathInfo info( localPath( dirname ) );
if( ! info.isDir() ) {
- ZYPP_THROW( MediaException, "Error::E_not_a_directory");
+ ZYPP_DOTHROW(MediaNotADirException(url(), localPath(dirname)));
}
#if NONREMOTE_DIRECTORY_YAST
// readdir
int res = readdir( retlist, info.path(), dots );
if ( res )
- ZYPP_THROW( MediaException, "Error::E_system");
+ ZYPP_DOTHROW(MediaSystemException(url(), "readdir failed"));
#if NONREMOTE_DIRECTORY_YAST
}
#endif
#include "zypp/Pathname.h"
#include "zypp/PathInfo.h"
-#warning FIXME use real Url class
-// #include "zypp/@Review/Url.h"
-typedef std::string Url;
+#include "zypp/Url.h"
#include "zypp/media/MediaAccess.h"
/**
* Protocol hint for MediaAccess.
**/
-#warning FIXME uncomment once real Url class is implemented
-#if 0
- Url::Protocol protocol() const { return _url.protocol(); }
-#endif
+ std::string protocol() const { return _url.getScheme(); }
/**
* Url used.