#include <MediaCIFS.h>
Public Member Functions | |
MediaCIFS (const Url &url_r, const Pathname &attach_point_hint_r) | |
virtual | ~MediaCIFS () |
virtual bool | isAttached () const |
True if media is attached. | |
Protected Member Functions | |
virtual void | attachTo (bool next=false) |
Asserted that not already attached, and attachPoint is a directory. | |
virtual void | releaseFrom (const std::string &ejectDev) |
Call concrete handler to release the media. | |
virtual void | getFile (const Pathname &filename) const |
Call concrete handler to provide file below attach point. | |
virtual void | getDir (const Pathname &dirname, bool recurse_r) const |
Call concrete handler to provide directory content (not recursive!) below attach point. | |
virtual void | getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const |
Call concrete handler to provide a content list of directory on media via retlist. | |
virtual void | getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const |
Basically the same as getDirInfo above. | |
virtual bool | getDoesFileExist (const Pathname &filename) const |
check if a file exists | |
Private Member Functions | |
bool | authenticate (AuthData &authdata, bool firstTry) const |
NOTE: The implementation serves both, "smb" and "cifs" URL's, but passes "cifs" to the mount command in any case.
Definition at line 32 of file MediaCIFS.h.
zypp::media::MediaCIFS::MediaCIFS | ( | const Url & | url_r, | |
const Pathname & | attach_point_hint_r | |||
) |
virtual zypp::media::MediaCIFS::~MediaCIFS | ( | ) | [inline, virtual] |
void zypp::media::MediaCIFS::attachTo | ( | bool | next = false |
) | [protected, virtual] |
Asserted that not already attached, and attachPoint is a directory.
Authentication: credentials can be specified in the following few ways (the first has the highest preference).
Implements zypp::media::MediaHandler.
Definition at line 132 of file MediaCIFS.cc.
References zypp::media::MediaHandler::_url, zypp::str::asString(), zypp::media::MediaHandler::attachPoint(), zypp::media::AttachedMedia::attachPoint, authenticate(), zypp::media::MediaHandler::createAttachPoint(), DBG, zypp::media::MediaHandler::findAttachedMedia(), zypp::media::CredentialManager::getCred(), zypp::Url::getHost(), zypp::Url::getPassword(), zypp::Url::getPathName(), zypp::Url::getQueryParam(), zypp::media::getShare(), zypp::Url::getUsername(), isAttached(), zypp::media::MediaHandler::isUseableAttachPoint(), zypp::media::AttachedMedia::mediaSource, zypp::media::Mount::mount(), zypp::media::MediaMountException::mountError(), zypp::media::AuthData::password(), zypp::filesystem::TmpPath::path(), zypp::media::MediaHandler::removeAttachPoint(), zypp::media::MediaHandler::setAttachPoint(), zypp::media::MediaHandler::setMediaSource(), zypp::media::Mount::umount(), zypp::media::MediaHandler::url(), zypp::media::AuthData::username(), ZYPP_CAUGHT, ZYPP_RETHROW, and ZYPP_THROW.
void zypp::media::MediaCIFS::releaseFrom | ( | const std::string & | ejectDev | ) | [protected, virtual] |
Call concrete handler to release the media.
If eject is true, and the media is used in one handler instance only, physically eject the media (i.e. CD-ROM).
Asserted that media is attached.
ejectDev | Device to eject. None if empty. |
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 346 of file MediaCIFS.cc.
References zypp::str::asString(), zypp::media::MediaHandler::attachPoint(), and zypp::media::Mount::umount().
void zypp::media::MediaCIFS::getFile | ( | const Pathname & | filename | ) | const [protected, virtual] |
Call concrete handler to provide file below attach point.
Default implementation provided, that returns whether a file is located at 'localRoot + filename'.
Asserted that media is attached.
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 359 of file MediaCIFS.cc.
void zypp::media::MediaCIFS::getDir | ( | const Pathname & | dirname, | |
bool | recurse_r | |||
) | const [protected, virtual] |
Call concrete handler to provide directory content (not recursive!) below attach point.
Return E_not_supported_by_media if media does not support retrieval of directory content.
Default implementation provided, that returns whether a directory is located at 'localRoot + dirname'.
Asserted that media is attached.
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 371 of file MediaCIFS.cc.
void zypp::media::MediaCIFS::getDirInfo | ( | std::list< std::string > & | retlist, | |
const Pathname & | dirname, | |||
bool | dots = true | |||
) | const [protected, virtual] |
Call concrete handler to provide a content list of directory on media via retlist.
If dots is false entries starting with '.' are not reported.
Return E_not_supported_by_media if media does not support retrieval of directory content.
Default implementation provided, that returns the content of a directory at 'localRoot + dirnname' retrieved via 'readdir'.
Asserted that media is attached and retlist is empty.
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 384 of file MediaCIFS.cc.
Referenced by getDirInfo().
void zypp::media::MediaCIFS::getDirInfo | ( | filesystem::DirContent & | retlist, | |
const Pathname & | dirname, | |||
bool | dots = true | |||
) | const [protected, virtual] |
Basically the same as getDirInfo above.
The content list is returned as filesystem::DirContent, which includes name and filetype of each directory entry. Retrieving the filetype usg. requires an additional stat call for each entry, thus it's more expensive than a simple readdir.
Asserted that media is attached and retlist is empty.
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 398 of file MediaCIFS.cc.
References getDirInfo().
bool zypp::media::MediaCIFS::getDoesFileExist | ( | const Pathname & | filename | ) | const [protected, virtual] |
check if a file exists
Asserted that url is a file and not a dir.
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 404 of file MediaCIFS.cc.
bool zypp::media::MediaCIFS::isAttached | ( | ) | const [virtual] |
True if media is attached.
Reimplemented from zypp::media::MediaHandler.
Definition at line 333 of file MediaCIFS.cc.
References zypp::media::MediaHandler::checkAttached().
Referenced by attachTo().
bool zypp::media::MediaCIFS::authenticate | ( | AuthData & | authdata, | |
bool | firstTry | |||
) | const [private] |
Definition at line 409 of file MediaCIFS.cc.
References _, zypp::media::MediaHandler::_url, zypp::media::CredentialManager::addCred(), zypp::Url::asString(), DBG, zypp::str::form(), zypp::media::CredentialManager::getCred(), zypp::Url::getUsername(), zypp::media::CredentialManager::save(), zypp::media::AuthData::setPassword(), and zypp::media::AuthData::setUsername().
Referenced by attachTo().