#include <MediaCD.h>
Public Member Functions | |
MediaCD (const Url &url_r, const Pathname &attach_point_hint_r) | |
virtual | ~MediaCD () |
virtual bool | isAttached () const |
True if media is attached. | |
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 | |
virtual void | forceEject (const std::string &ejectDev) |
Call concrete handler to physically eject the media (i.e. | |
virtual bool | isAutoMountedMedia (const AttachedMedia &media) |
virtual bool | hasMoreDevices () |
Check if the media has one more device available for attach(true). | |
virtual void | getDetectedDevices (std::vector< std::string > &devices, unsigned int &index) const |
Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector. | |
Private Types | |
typedef std::list< MediaSource > | DeviceList |
Private Member Functions | |
DeviceList | detectDevices (bool supportingDVD) const |
Static Private Member Functions | |
static bool | openTray (const std::string &device_r) |
static bool | closeTray (const std::string &device_r) |
Private Attributes | |
DeviceList | _devices |
list of devices to try to mount | |
int | _lastdev |
number of last successful mounted device in list | |
int | _lastdev_tried |
Definition at line 28 of file MediaCD.h.
typedef std::list<MediaSource> zypp::media::MediaCD::DeviceList [private] |
zypp::media::MediaCD::MediaCD | ( | const Url & | url_r, | |
const Pathname & | attach_point_hint_r | |||
) |
Definition at line 80 of file MediaCD.cc.
References _devices, zypp::media::MediaHandler::_url, zypp::Url::asString(), DBG, ERR, zypp::Url::getQueryParam(), zypp::Url::getScheme(), MIL, and ZYPP_THROW.
virtual zypp::media::MediaCD::~MediaCD | ( | ) | [inline, virtual] |
bool zypp::media::MediaCD::openTray | ( | const std::string & | device_r | ) | [static, private] |
Definition at line 136 of file MediaCD.cc.
References zypp::ExternalProgram::close(), DBG, EJECT_TOOL_PATH, MIL, zypp::externalprogram::ExternalDataSource::receiveLine(), zypp::ExternalProgram::Stderr_To_Stdout, zypp::str::strerror(), and WAR.
Referenced by forceEject(), and releaseFrom().
bool zypp::media::MediaCD::closeTray | ( | const std::string & | device_r | ) | [static, private] |
Definition at line 195 of file MediaCD.cc.
References DBG, zypp::str::strerror(), and WAR.
Referenced by attachTo().
MediaCD::DeviceList zypp::media::MediaCD::detectDevices | ( | bool | supportingDVD | ) | const [private] |
Definition at line 219 of file MediaCD.cc.
References DBG, WAR, and ZYPP_CAUGHT.
Referenced by attachTo(), forceEject(), and getDetectedDevices().
void zypp::media::MediaCD::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 310 of file MediaCD.cc.
References _devices, _lastdev, _lastdev_tried, zypp::media::MediaHandler::_url, zypp::Url::asString(), zypp::str::asString(), zypp::media::AttachedMedia::attachPoint, zypp::media::MediaHandler::attachPoint(), closeTray(), zypp::media::MediaHandler::createAttachPoint(), DBG, detectDevices(), zypp::media::MediaSource::equals(), zypp::media::MediaHandler::findAttachedMedia(), zypp::media::MediaManager::getMountEntries(), zypp::Url::getQueryParam(), zypp::Url::getScheme(), isAttached(), isAutoMountedMedia(), zypp::media::MediaHandler::isUseableAttachPoint(), zypp::media::MediaSource::maj_nr, zypp::media::AttachedMedia::mediaSource, zypp::media::MediaSource::min_nr, zypp::media::Mount::mount(), zypp::media::MediaMountException::mountError(), zypp::media::MediaMountException::mountOutput(), zypp::media::MediaSource::name, zypp::media::MediaHandler::removeAttachPoint(), zypp::media::MediaHandler::setAttachPoint(), zypp::media::MediaHandler::setMediaSource(), zypp::media::Mount::umount(), zypp::media::MediaHandler::url(), ZYPP_CAUGHT, and ZYPP_THROW.
void zypp::media::MediaCD::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 575 of file MediaCD.cc.
References zypp::media::MediaHandler::attachedMedia(), zypp::media::AttachedMedia::attachPoint, FORCE_RELEASE_FOREIGN, zypp::media::MediaHandler::forceRelaseAllMedia(), zypp::media::AttachedMedia::mediaSource, openTray(), zypp::media::Mount::umount(), ZYPP_CAUGHT, ZYPP_RETHROW, and ZYPP_THROW.
void zypp::media::MediaCD::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 798 of file MediaCD.cc.
void zypp::media::MediaCD::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 810 of file MediaCD.cc.
void zypp::media::MediaCD::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 823 of file MediaCD.cc.
Referenced by getDirInfo().
void zypp::media::MediaCD::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 837 of file MediaCD.cc.
References getDirInfo().
bool zypp::media::MediaCD::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 843 of file MediaCD.cc.
void zypp::media::MediaCD::forceEject | ( | const std::string & | device | ) | [protected, virtual] |
Call concrete handler to physically eject the media (i.e.
CD-ROM) in case the media is not attached..
Asserted that media is not attached.
Reimplemented from zypp::media::MediaHandler.
Definition at line 623 of file MediaCD.cc.
References _devices, zypp::media::MediaHandler::_url, DBG, detectDevices(), zypp::media::MediaHandler::findAttachedMedia(), FORCE_RELEASE_FOREIGN, zypp::media::MediaHandler::forceRelaseAllMedia(), zypp::Url::getScheme(), isAttached(), zypp::media::AttachedMedia::mediaSource, openTray(), and ZYPP_THROW.
bool zypp::media::MediaCD::isAutoMountedMedia | ( | const AttachedMedia & | media | ) | [protected, virtual] |
Reimplemented from zypp::media::MediaHandler.
Definition at line 715 of file MediaCD.cc.
References zypp::media::AttachedMedia::attachPoint, DBG, INT, zypp::media::AttachedMedia::mediaSource, and ZYPP_CAUGHT.
Referenced by attachTo().
bool zypp::media::MediaCD::hasMoreDevices | ( | ) | [protected, virtual] |
Check if the media has one more device available for attach(true).
Reimplemented from zypp::media::MediaHandler.
Definition at line 848 of file MediaCD.cc.
References _devices, and _lastdev_tried.
void zypp::media::MediaCD::getDetectedDevices | ( | std::vector< std::string > & | devices, | |
unsigned int & | index | |||
) | const [protected, virtual] |
Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.
The contents of the vector are the device names (/dev/cdrom and such).
devices | vector to load with the device names | |
index | index of the currently used device in the devices vector |
Reimplemented from zypp::media::MediaHandler.
Definition at line 859 of file MediaCD.cc.
References _devices, _lastdev, zypp::media::MediaHandler::_url, DBG, detectDevices(), zypp::Url::getScheme(), and MIL.
bool zypp::media::MediaCD::isAttached | ( | ) | const [virtual] |
True if media is attached.
Reimplemented from zypp::media::MediaHandler.
Definition at line 786 of file MediaCD.cc.
References zypp::media::MediaHandler::checkAttached().
Referenced by attachTo(), and forceEject().
DeviceList zypp::media::MediaCD::_devices [private] |
list of devices to try to mount
Definition at line 34 of file MediaCD.h.
Referenced by attachTo(), forceEject(), getDetectedDevices(), hasMoreDevices(), and MediaCD().
int zypp::media::MediaCD::_lastdev [private] |
number of last successful mounted device in list
Definition at line 37 of file MediaCD.h.
Referenced by attachTo(), and getDetectedDevices().
int zypp::media::MediaCD::_lastdev_tried [private] |