#include <MediaDISK.h>
Public Member Functions | |
MediaDISK (const Url &url_r, const Pathname &attach_point_hint_r) | |
virtual | ~MediaDISK () |
virtual bool | isAttached () const |
True if media is attached. | |
bool | verifyIfDiskVolume (const Pathname &name) |
Protected Member Functions | |
virtual void | attachTo (bool next=false) |
Call concrete handler to attach the media. | |
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 Attributes | |
unsigned long | _mountflags |
std::string | _device |
std::string | _filesystem |
Definition at line 27 of file MediaDISK.h.
zypp::media::MediaDISK::MediaDISK | ( | const Url & | url_r, | |
const Pathname & | attach_point_hint_r | |||
) |
Definition at line 63 of file MediaDISK.cc.
References _device, _filesystem, zypp::media::MediaHandler::_url, zypp::str::asString(), DBG, ERR, zypp::Url::getQueryParam(), MIL, verifyIfDiskVolume(), and ZYPP_THROW.
virtual zypp::media::MediaDISK::~MediaDISK | ( | ) | [inline, virtual] |
void zypp::media::MediaDISK::attachTo | ( | bool | next = false |
) | [protected, virtual] |
Call concrete handler to attach the media.
Asserted that not already attached, and attachPoint is a directory.
next | try next available device in turn until end of device list is reached (for media which are accessible through multiple devices like cdroms). |
MediaException |
Implements zypp::media::MediaHandler.
Definition at line 246 of file MediaDISK.cc.
References _device, _filesystem, zypp::media::MediaHandler::_url, zypp::str::asString(), zypp::media::MediaHandler::attachPoint(), zypp::media::AttachedMedia::attachPoint, zypp::media::MediaHandler::createAttachPoint(), DBG, zypp::media::MediaHandler::findAttachedMedia(), zypp::media::MediaManager::getMountEntries(), zypp::Url::getQueryParam(), isAttached(), zypp::media::MediaHandler::isAutoMountedMedia(), zypp::media::MediaHandler::isUseableAttachPoint(), zypp::media::AttachedMedia::mediaSource, zypp::media::Mount::mount(), zypp::media::MediaHandler::removeAttachPoint(), zypp::media::MediaHandler::setAttachPoint(), zypp::media::MediaHandler::setMediaSource(), zypp::media::Mount::umount(), zypp::media::MediaHandler::url(), verifyIfDiskVolume(), ZYPP_CAUGHT, and ZYPP_THROW.
void zypp::media::MediaDISK::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 416 of file MediaDISK.cc.
References zypp::str::asString(), zypp::media::MediaHandler::attachedMedia(), zypp::media::MediaHandler::attachPoint(), zypp::media::AttachedMedia::mediaSource, and zypp::media::Mount::umount().
void zypp::media::MediaDISK::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 433 of file MediaDISK.cc.
void zypp::media::MediaDISK::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 445 of file MediaDISK.cc.
void zypp::media::MediaDISK::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 458 of file MediaDISK.cc.
Referenced by getDirInfo().
void zypp::media::MediaDISK::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 472 of file MediaDISK.cc.
References getDirInfo().
bool zypp::media::MediaDISK::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 478 of file MediaDISK.cc.
bool zypp::media::MediaDISK::isAttached | ( | ) | const [virtual] |
True if media is attached.
Reimplemented from zypp::media::MediaHandler.
Definition at line 403 of file MediaDISK.cc.
References zypp::media::MediaHandler::checkAttached().
Referenced by attachTo().
bool zypp::media::MediaDISK::verifyIfDiskVolume | ( | const Pathname & | name | ) |
Definition at line 100 of file MediaDISK.cc.
References zypp::ExternalProgram::close(), DBG, ERR, zypp::filesystem::readdir(), zypp::externalprogram::ExternalDataSource::receiveLine(), zypp::str::rtrim(), zypp::ExternalProgram::Stderr_To_Stdout, and VOL_ID_TOOL_PATHS.
Referenced by attachTo(), and MediaDISK().
unsigned long zypp::media::MediaDISK::_mountflags [private] |
Definition at line 31 of file MediaDISK.h.
std::string zypp::media::MediaDISK::_device [private] |
std::string zypp::media::MediaDISK::_filesystem [private] |